diff --git a/test/src/specs/rpc/truncate.rs b/test/src/specs/rpc/truncate.rs index a1002ff8c8..da2251972f 100644 --- a/test/src/specs/rpc/truncate.rs +++ b/test/src/specs/rpc/truncate.rs @@ -31,6 +31,7 @@ impl Spec for RpcTruncate { let tx_pool_info = node.get_tip_tx_pool_info(); assert!(tx_pool_info.total_tx_size.value() > 0, "tx-pool holds tx2"); + assert!(tx_pool_info.pending.value() > 0, "tx-pool hods tx2"); // Truncate from `to_truncate` diff --git a/tx-pool/src/component/pool_map.rs b/tx-pool/src/component/pool_map.rs index 184cc522ba..aea59e74bb 100644 --- a/tx-pool/src/component/pool_map.rs +++ b/tx-pool/src/component/pool_map.rs @@ -365,6 +365,9 @@ impl PoolMap { self.links.clear(); self.total_tx_size = 0; self.total_tx_cycles = 0; + self.pending_count = 0; + self.gap_count = 0; + self.proposed_count = 0; } pub(crate) fn score_sorted_iter_by( @@ -628,7 +631,7 @@ impl PoolMap { }); } - pub fn track_entry_statics(&mut self, remove: Option, add: Option) { + fn track_entry_statics(&mut self, remove: Option, add: Option) { match remove { Some(Status::Pending) => self.pending_count -= 1, Some(Status::Gap) => self.gap_count -= 1, diff --git a/tx-pool/src/component/tests/proposed.rs b/tx-pool/src/component/tests/proposed.rs index bf2f447886..236d4b10a9 100644 --- a/tx-pool/src/component/tests/proposed.rs +++ b/tx-pool/src/component/tests/proposed.rs @@ -3,10 +3,8 @@ use crate::component::tests::util::{ build_tx, build_tx_with_dep, build_tx_with_header_dep, DEFAULT_MAX_ANCESTORS_COUNT, MOCK_CYCLES, MOCK_FEE, MOCK_SIZE, }; -use ckb_types::core::capacity_bytes; -use ckb_types::core::ScriptHashType; -use ckb_types::packed::CellOutputBuilder; -use ckb_types::packed::ScriptBuilder; +use ckb_types::core::{capacity_bytes, ScriptHashType}; +use ckb_types::packed::{CellOutputBuilder, ScriptBuilder}; use ckb_types::H256; use std::time::Instant; @@ -793,7 +791,7 @@ fn test_pool_map_bench() { let first = time_spend[0].as_millis(); let last = time_spend.last().unwrap().as_millis(); let diff = (last as i128 - first as i128).abs(); - let expect_diff_range = ((first as f64) * 0.15) as i128; + let expect_diff_range = ((first as f64) * 2.0) as i128; eprintln!( "first: {} last: {}, diff: {}, range: {}", first, last, diff, expect_diff_range