Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions crates/rpc/rpc-eth-api/src/helpers/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,18 @@ pub trait EthFees:
let start_block = end_block_plus - block_count;

// Collect base fees, gas usage ratios and (optionally) reward percentile data
let mut base_fee_per_gas: Vec<u128> = Vec::new();
let mut gas_used_ratio: Vec<f64> = Vec::new();
// Pre-allocate capacity: base_fee and blob_fee need +1 for the next block's fee
let mut base_fee_per_gas: Vec<u128> = Vec::with_capacity(block_count as usize + 1);
let mut gas_used_ratio: Vec<f64> = Vec::with_capacity(block_count as usize);

let mut base_fee_per_blob_gas: Vec<u128> = Vec::new();
let mut blob_gas_used_ratio: Vec<f64> = Vec::new();
let mut base_fee_per_blob_gas: Vec<u128> = Vec::with_capacity(block_count as usize + 1);
let mut blob_gas_used_ratio: Vec<f64> = Vec::with_capacity(block_count as usize);

let mut rewards: Vec<Vec<u128>> = Vec::new();
let mut rewards: Vec<Vec<u128>> = if reward_percentiles.is_some() {
Vec::with_capacity(block_count as usize)
} else {
Vec::new()
};

// Check if the requested range is within the cache bounds
let fee_entries = self.fee_history_cache().get_history(start_block, end_block).await;
Expand Down
Loading