Skip to content

Commit

Permalink
get_fee_rate_statistics should aware block_ext.txs_sizes length i…
Browse files Browse the repository at this point in the history
…s `block_ext.txs_fees` length + 1

Signed-off-by: Eval EXEC <[email protected]>
  • Loading branch information
eval-exec committed Sep 21, 2024
1 parent 44afc93 commit 1c03ef2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions rpc/src/util/fee_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,16 @@ 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.len() > 1
if block_ext.txs_sizes.len() > 1
&& block_ext.cycles.is_some()
&& block_ext.txs_sizes.is_some()
&& block_ext.txs_fees.is_some()
{
// block_ext.txs_fees, cycles, txs_sizes length is same
// block_ext.txs_fees and cycles's length + 1 is equal to txs_sizes's length
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)
{
block_ext.txs_sizes.expect("checked").iter().skip(1) // skip cellbase (first element in the Vec)
) {
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 1c03ef2

Please sign in to comment.