Skip to content

Commit

Permalink
fix sepc RpcTruncate
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Mar 14, 2024
1 parent 96ccb0d commit 4b715ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions test/src/specs/rpc/truncate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
5 changes: 4 additions & 1 deletion tx-pool/src/component/pool_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -628,7 +631,7 @@ impl PoolMap {
});
}

pub fn track_entry_statics(&mut self, remove: Option<Status>, add: Option<Status>) {
fn track_entry_statics(&mut self, remove: Option<Status>, add: Option<Status>) {
match remove {
Some(Status::Pending) => self.pending_count -= 1,
Some(Status::Gap) => self.gap_count -= 1,
Expand Down
8 changes: 3 additions & 5 deletions tx-pool/src/component/tests/proposed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4b715ff

Please sign in to comment.