Skip to content

Commit

Permalink
Merge branch 'develop' into zhangsoledad/preview-init
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsoledad authored Sep 14, 2024
2 parents abacc95 + e0b4489 commit 3fd4a4c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions block-filter/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ impl BlockFilter {
};

for block_number in start_number..=tip_header.number() {
if ckb_stop_handler::has_received_stop_signal() {
info!("ckb has received stop signal, BlockFilter exit now");
return;
}

let block_hash = snapshot.get_block_hash(block_number).expect("index stored");
let header = snapshot
.get_block_header(&block_hash)
Expand Down
13 changes: 10 additions & 3 deletions rpc/src/tests/fee_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,16 @@ fn test_fee_rate_statics() {
total_difficulty: 0u64.into(),
total_uncles_count: 0,
verified: None,
txs_fees: vec![Capacity::shannons(i * i * 100)],
cycles: Some(vec![i * 100]),
txs_sizes: Some(vec![i * 100]),

// first element in txs_fees is belong to cellbase
txs_fees: vec![
Capacity::shannons(i * 1234),
Capacity::shannons(i * i * 100),
],
// first element in cycles is belong to cellbase
cycles: Some(vec![0, i * 100]),
// first element in txs_sizes is belong to cellbase
txs_sizes: Some(vec![i * 5678, i * 100]),
};
provider.append(i, ext);
}
Expand Down
8 changes: 6 additions & 2 deletions rpc/src/util/fee_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ where
target = std::cmp::min(self.provider.max_target(), target);

let mut fee_rates = self.provider.collect(target, |mut fee_rates, block_ext| {
if !block_ext.txs_fees.is_empty()
if block_ext.txs_fees.len() > 1
&& block_ext.cycles.is_some()
&& block_ext.txs_sizes.is_some()
{
// block_ext.txs_fees, cycles, txs_sizes length is same
for (fee, cycles, size) in itertools::izip!(
block_ext.txs_fees,
block_ext.cycles.expect("checked"),
block_ext.txs_sizes.expect("checked")
) {
)
// skip cellbase (first element in the Vec)
.skip(1)
{
let weight = get_transaction_weight(size as usize, cycles);
if weight > 0 {
fee_rates.push(FeeRate::calculate(fee, weight).as_u64());
Expand Down

0 comments on commit 3fd4a4c

Please sign in to comment.