mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
perf(rpc): improve gas price perf by skipping hash (#2657)
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
use crate::{executor::Error as ExecutionError, Error};
|
||||
use reth_primitives::{BlockHash, BlockNumHash, BlockNumber, SealedBlock, SealedBlockWithSenders};
|
||||
use reth_primitives::{
|
||||
BlockHash, BlockNumHash, BlockNumber, SealedBlock, SealedBlockWithSenders, SealedHeader,
|
||||
};
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
||||
/// * [BlockchainTreeEngine::insert_block]: Connect block to chain, execute it and if valid insert
|
||||
@ -90,6 +92,11 @@ pub trait BlockchainTreeViewer: Send + Sync {
|
||||
/// Caution: This will not return blocks from the canonical chain.
|
||||
fn blocks(&self) -> BTreeMap<BlockNumber, HashSet<BlockHash>>;
|
||||
|
||||
/// Returns the header with matching hash from the tree, if it exists.
|
||||
///
|
||||
/// Caution: This will not return headers from the canonical chain.
|
||||
fn header_by_hash(&self, hash: BlockHash) -> Option<SealedHeader>;
|
||||
|
||||
/// Returns the block with matching hash from the tree, if it exists.
|
||||
///
|
||||
/// Caution: This will not return blocks from the canonical chain.
|
||||
@ -124,4 +131,9 @@ pub trait BlockchainTreeViewer: Send + Sync {
|
||||
fn pending_block(&self) -> Option<SealedBlock> {
|
||||
self.block_by_hash(self.pending_block_num_hash()?.hash)
|
||||
}
|
||||
|
||||
/// Returns the pending block if there is one.
|
||||
fn pending_header(&self) -> Option<SealedHeader> {
|
||||
self.header_by_hash(self.pending_block_num_hash()?.hash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user