block_with_senders in ethstatecache (#5302)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Supernovahs.eth
2023-11-20 20:26:08 +05:30
committed by GitHub
parent 1cc68fcca6
commit 3c7989c541
18 changed files with 239 additions and 82 deletions

View File

@@ -237,6 +237,12 @@ pub trait BlockchainTreeViewer: Send + Sync {
/// disconnected from the canonical chain.
fn block_by_hash(&self, hash: BlockHash) -> Option<SealedBlock>;
/// Returns the block with matching hash from the tree, if it exists.
///
/// Caution: This will not return blocks from the canonical chain or buffered blocks that are
/// disconnected from the canonical chain.
fn block_with_senders_by_hash(&self, hash: BlockHash) -> Option<SealedBlockWithSenders>;
/// Returns the _buffered_ (disconnected) block with matching hash from the internal buffer if
/// it exists.
///
@@ -295,6 +301,11 @@ pub trait BlockchainTreeViewer: Send + Sync {
self.block_by_hash(self.pending_block_num_hash()?.hash)
}
/// Returns the pending block if there is one.
fn pending_block_with_senders(&self) -> Option<SealedBlockWithSenders> {
self.block_with_senders_by_hash(self.pending_block_num_hash()?.hash)
}
/// Returns the pending block and its receipts in one call.
///
/// This exists to prevent a potential data race if the pending block changes in between