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 <execvy@gmail.com>
  • Loading branch information
eval-exec committed Sep 21, 2024
1 parent 44afc93 commit cdb1fe1
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions rpc/src/util/fee_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +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
&& block_ext.cycles.is_some()
&& block_ext.txs_sizes.is_some()
{
// block_ext.txs_fees, cycles, txs_sizes length is same
let txs_sizes = block_ext.txs_sizes.expect("expect txs_size's length >= 1");
if txs_sizes.len() > 1 && block_ext.cycles.is_some() && !block_ext.txs_fees.is_empty() {
// block_ext.txs_fees's length == block_ext.cycles's length
// block_ext.txs_fees's length + 1 == 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)
{
let weight = get_transaction_weight(size as usize, cycles);
txs_sizes.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 cdb1fe1

Please sign in to comment.