mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: ensure we can handle pending target for feeHistory (#9904)
This commit is contained in:
@ -50,7 +50,7 @@ pub trait EthFees: LoadFee {
|
||||
fn fee_history(
|
||||
&self,
|
||||
mut block_count: u64,
|
||||
newest_block: BlockNumberOrTag,
|
||||
mut newest_block: BlockNumberOrTag,
|
||||
reward_percentiles: Option<Vec<f64>>,
|
||||
) -> impl Future<Output = Result<FeeHistory, Self::Error>> + Send {
|
||||
async move {
|
||||
@ -74,6 +74,13 @@ pub trait EthFees: LoadFee {
|
||||
block_count = max_fee_history
|
||||
}
|
||||
|
||||
if newest_block.is_pending() {
|
||||
// cap the target block since we don't have fee history for the pending block
|
||||
newest_block = BlockNumberOrTag::Latest;
|
||||
// account for missing pending block
|
||||
block_count = block_count.saturating_sub(1);
|
||||
}
|
||||
|
||||
let Some(end_block) = LoadFee::provider(self)
|
||||
.block_number_for_id(newest_block.into())
|
||||
.map_err(Self::Error::from_eth_err)?
|
||||
|
||||
Reference in New Issue
Block a user