mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
block_with_senders in ethstatecache (#5302)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -209,10 +209,22 @@ impl<DB: Database, EF: ExecutorFactory> BlockchainTree<DB, EF> {
|
||||
/// Returns the block with matching hash from any side-chain.
|
||||
///
|
||||
/// Caution: This will not return blocks from the canonical chain.
|
||||
#[inline]
|
||||
pub fn block_by_hash(&self, block_hash: BlockHash) -> Option<&SealedBlock> {
|
||||
self.state.block_by_hash(block_hash)
|
||||
}
|
||||
|
||||
/// Returns the block with matching hash from any side-chain.
|
||||
///
|
||||
/// Caution: This will not return blocks from the canonical chain.
|
||||
#[inline]
|
||||
pub fn block_with_senders_by_hash(
|
||||
&self,
|
||||
block_hash: BlockHash,
|
||||
) -> Option<&SealedBlockWithSenders> {
|
||||
self.state.block_with_senders_by_hash(block_hash)
|
||||
}
|
||||
|
||||
/// Returns the block's receipts with matching hash from any side-chain.
|
||||
///
|
||||
/// Caution: This will not return blocks from the canonical chain.
|
||||
|
||||
@@ -74,6 +74,10 @@ impl BlockchainTreeViewer for NoopBlockchainTree {
|
||||
None
|
||||
}
|
||||
|
||||
fn block_with_senders_by_hash(&self, _hash: BlockHash) -> Option<SealedBlockWithSenders> {
|
||||
None
|
||||
}
|
||||
|
||||
fn buffered_block_by_hash(&self, _block_hash: BlockHash) -> Option<SealedBlock> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -117,6 +117,11 @@ impl<DB: Database, EF: ExecutorFactory> BlockchainTreeViewer for ShareableBlockc
|
||||
self.tree.read().block_by_hash(block_hash).cloned()
|
||||
}
|
||||
|
||||
fn block_with_senders_by_hash(&self, block_hash: BlockHash) -> Option<SealedBlockWithSenders> {
|
||||
trace!(target: "blockchain_tree", ?block_hash, "Returning block by hash");
|
||||
self.tree.read().block_with_senders_by_hash(block_hash).cloned()
|
||||
}
|
||||
|
||||
fn buffered_block_by_hash(&self, block_hash: BlockHash) -> Option<SealedBlock> {
|
||||
self.tree.read().get_buffered_block(&block_hash).map(|b| b.block.clone())
|
||||
}
|
||||
|
||||
@@ -56,10 +56,21 @@ impl TreeState {
|
||||
/// Returns the block with matching hash from any side-chain.
|
||||
///
|
||||
/// Caution: This will not return blocks from the canonical chain.
|
||||
#[inline]
|
||||
pub(crate) fn block_by_hash(&self, block_hash: BlockHash) -> Option<&SealedBlock> {
|
||||
self.block_with_senders_by_hash(block_hash).map(|block| &block.block)
|
||||
}
|
||||
/// Returns the block with matching hash from any side-chain.
|
||||
///
|
||||
/// Caution: This will not return blocks from the canonical chain.
|
||||
#[inline]
|
||||
pub(crate) fn block_with_senders_by_hash(
|
||||
&self,
|
||||
block_hash: BlockHash,
|
||||
) -> Option<&SealedBlockWithSenders> {
|
||||
let id = self.block_indices.get_blocks_chain_id(&block_hash)?;
|
||||
let chain = self.chains.get(&id)?;
|
||||
chain.block(block_hash)
|
||||
chain.block_with_senders(block_hash)
|
||||
}
|
||||
|
||||
/// Returns the block's receipts with matching hash from any side-chain.
|
||||
|
||||
Reference in New Issue
Block a user