Skip to content

Commit

Permalink
refactor: use TransactionVec to persist tx pool
Browse files Browse the repository at this point in the history
  • Loading branch information
quake committed Aug 4, 2021
1 parent d60d154 commit 6a17fd2
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 707 deletions.
83 changes: 0 additions & 83 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ckb-bin/src/subcommand/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn replay(args: ReplayArgs, async_handle: Handle) -> Result<(), ExitCode> {
)?;
let (shared, _) = shared_builder
.consensus(args.consensus.clone())
.tx_pool_config(args.config.tx_pool)
.tx_pool_config(args.config.tx_pool.clone())
.build()?;

if !args.tmp_target.is_dir() {
Expand Down
16 changes: 4 additions & 12 deletions ckb-bin/src/subcommand/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,10 @@ pub fn run(args: RunArgs, version: Version, async_handle: Handle) -> Result<(),
exit_handler.wait_for_exit();

info!("Finishing work, please wait...");
shared.tx_pool_controller().save_pool().map_err(|err| {
eprintln!("TxPool Error: {}", err);
ExitCode::Failure
})?;
drop(rpc_server);
drop(network_controller);
shared
.tx_pool_controller()
.persist_tx_pool()
.map_err(|err| {
eprintln!("TxPool Error: {}", err);
ExitCode::Failure
})?
.map_err(|err| {
eprintln!("TxPool Error: {}", err);
ExitCode::Failure
})?;
Ok(())
}
2 changes: 1 addition & 1 deletion test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ lazy_static = "1.4.0"
byteorder = "1.3.1"
jsonrpc-core = "18.0"

[target.'cfg(target_os="linux")'.dependencies]
[target.'cfg(not(target_os="windows"))'.dependencies]
nix = "0.20.0"

# Prevent this from interfering with workspaces
Expand Down
2 changes: 1 addition & 1 deletion test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ fn all_specs() -> Vec<Box<dyn Spec>> {
Box::new(TemplateSizeLimit),
Box::new(PoolReconcile),
Box::new(PoolResurrect),
#[cfg(target_os = "linux")]
#[cfg(not(target_os = "windows"))]
Box::new(PoolPersisted),
Box::new(TransactionRelayBasic),
Box::new(TransactionRelayLowFeeRate),
Expand Down
2 changes: 1 addition & 1 deletion test/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl Node {
drop(self.guard.take())
}

#[cfg(target_os = "linux")]
#[cfg(not(target_os = "windows"))]
pub fn stop_gracefully(&mut self) {
if let Some(mut guard) = self.guard.take() {
if !guard.killed {
Expand Down
4 changes: 2 additions & 2 deletions test/src/specs/tx_pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod depend_tx_in_same_block;
mod descendant;
mod different_txs_with_same_input;
mod limit;
#[cfg(target_os = "linux")]
#[cfg(not(target_os = "windows"))]
mod pool_persisted;
mod pool_reconcile;
mod pool_resurrect;
Expand All @@ -29,7 +29,7 @@ pub use depend_tx_in_same_block::*;
pub use descendant::*;
pub use different_txs_with_same_input::*;
pub use limit::*;
#[cfg(target_os = "linux")]
#[cfg(not(target_os = "windows"))]
pub use pool_persisted::*;
pub use pool_reconcile::*;
pub use pool_resurrect::*;
Expand Down
12 changes: 8 additions & 4 deletions test/src/specs/tx_pool/pool_persisted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ impl Spec for PoolPersisted {

let tx_pool_info_reloaded = node0.get_tip_tx_pool_info();
info!("TxPool should be same as before");
assert_eq!(tx_pool_info_original, tx_pool_info_reloaded);
assert_eq!(
tx_pool_info_original.total_tx_size,
tx_pool_info_reloaded.total_tx_size
);
assert_eq!(
tx_pool_info_original.total_tx_cycles,
tx_pool_info_reloaded.total_tx_cycles
);

info!("Check the specific values of TxPool state");
node0.assert_tx_pool_size(txs_hash2.len() as u64, txs_hash1.len() as u64);
assert!(tx_pool_info_reloaded.total_tx_size.value() > 0);
assert!(tx_pool_info_reloaded.total_tx_cycles.value() > 0);
assert!(tx_pool_info_reloaded.last_txs_updated_at.value() > 0);
}
}
18 changes: 0 additions & 18 deletions tx-pool/build.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tx-pool/schemas/persisted.mol

This file was deleted.

67 changes: 0 additions & 67 deletions tx-pool/schemas/referenced.mol

This file was deleted.

Loading

0 comments on commit 6a17fd2

Please sign in to comment.