reth_engine_tree

Trait BlockchainTreeViewer

pub trait BlockchainTreeViewer: Send + Sync {
Show 15 methods // Required methods fn header_by_hash(&self, hash: FixedBytes<32>) -> Option<SealedHeader>; fn block_by_hash(&self, hash: FixedBytes<32>) -> Option<SealedBlock>; fn block_with_senders_by_hash( &self, hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>; fn buffered_header_by_hash( &self, block_hash: FixedBytes<32>, ) -> Option<SealedHeader>; fn is_canonical(&self, hash: FixedBytes<32>) -> Result<bool, ProviderError>; fn lowest_buffered_ancestor( &self, hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>; fn canonical_tip(&self) -> NumHash; fn pending_block_num_hash(&self) -> Option<NumHash>; fn pending_block_and_receipts(&self) -> Option<(SealedBlock, Vec<Receipt>)>; fn receipts_by_block_hash( &self, block_hash: FixedBytes<32>, ) -> Option<Vec<Receipt>>; // Provided methods fn contains(&self, hash: FixedBytes<32>) -> bool { ... } fn pending_block(&self) -> Option<SealedBlock> { ... } fn pending_block_with_senders(&self) -> Option<SealedBlockWithSenders> { ... } fn pending_receipts(&self) -> Option<Vec<Receipt>> { ... } fn pending_header(&self) -> Option<SealedHeader> { ... }
}
Expand description

Re-export of the blockchain tree API. Allows read only functionality on the blockchain tree.

Tree contains all blocks that are not canonical that can potentially be included as canonical chain. For better explanation we can group blocks into four groups:

  • Canonical chain blocks
  • Side chain blocks. Side chain are block that forks from canonical chain but not its tip.
  • Pending blocks that extend the canonical chain but are not yet included.
  • Future pending blocks that extend the pending blocks.

Required Methods§

fn header_by_hash(&self, hash: FixedBytes<32>) -> Option<SealedHeader>

Returns the header with matching hash from the tree, if it exists.

Caution: This will not return headers from the canonical chain.

fn block_by_hash(&self, hash: FixedBytes<32>) -> 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: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>

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 buffered_header_by_hash( &self, block_hash: FixedBytes<32>, ) -> Option<SealedHeader>

Returns the buffered (disconnected) header with matching hash from the internal buffer if it exists.

Caution: Unlike Self::block_by_hash this will only return headers that are currently disconnected from the canonical chain.

fn is_canonical(&self, hash: FixedBytes<32>) -> Result<bool, ProviderError>

Return whether or not the block is known and in the canonical chain.

fn lowest_buffered_ancestor( &self, hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>

Given the hash of a block, this checks the buffered blocks for the lowest ancestor in the buffer.

If there is a buffered block with the given hash, this returns the block itself.

fn canonical_tip(&self) -> NumHash

Return BlockchainTree best known canonical chain tip (BlockHash, BlockNumber)

fn pending_block_num_hash(&self) -> Option<NumHash>

Return block number and hash that extends the canonical chain tip by one.

If there is no such block, this returns None.

fn pending_block_and_receipts(&self) -> Option<(SealedBlock, Vec<Receipt>)>

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 Self::pending_block and Self::pending_receipts calls.

fn receipts_by_block_hash( &self, block_hash: FixedBytes<32>, ) -> Option<Vec<Receipt>>

Returns the pending receipts if there is one.

Provided Methods§

fn contains(&self, hash: FixedBytes<32>) -> bool

Returns true if the tree contains the block with matching hash.

fn pending_block(&self) -> Option<SealedBlock>

Returns the pending block if there is one.

fn pending_block_with_senders(&self) -> Option<SealedBlockWithSenders>

Returns the pending block if there is one.

fn pending_receipts(&self) -> Option<Vec<Receipt>>

Returns the pending receipts if there is one.

fn pending_header(&self) -> Option<SealedHeader>

Returns the pending block if there is one.

Implementations on Foreign Types§

§

impl BlockchainTreeViewer for NoopBlockchainTree

§

fn header_by_hash(&self, _hash: FixedBytes<32>) -> Option<SealedHeader>

§

fn block_by_hash(&self, _hash: FixedBytes<32>) -> Option<SealedBlock>

§

fn block_with_senders_by_hash( &self, _hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>

§

fn buffered_header_by_hash( &self, _block_hash: FixedBytes<32>, ) -> Option<SealedHeader>

§

fn is_canonical( &self, _block_hash: FixedBytes<32>, ) -> Result<bool, ProviderError>

§

fn lowest_buffered_ancestor( &self, _hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>

§

fn canonical_tip(&self) -> NumHash

§

fn pending_block_num_hash(&self) -> Option<NumHash>

§

fn pending_block_and_receipts(&self) -> Option<(SealedBlock, Vec<Receipt>)>

§

fn receipts_by_block_hash( &self, _block_hash: FixedBytes<32>, ) -> Option<Vec<Receipt>>

Source§

impl<N> BlockchainTreeViewer for BlockchainProvider<N>

Source§

fn header_by_hash(&self, hash: FixedBytes<32>) -> Option<SealedHeader>

Source§

fn block_by_hash(&self, block_hash: FixedBytes<32>) -> Option<SealedBlock>

Source§

fn block_with_senders_by_hash( &self, block_hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>

Source§

fn buffered_header_by_hash( &self, block_hash: FixedBytes<32>, ) -> Option<SealedHeader>

Source§

fn is_canonical(&self, hash: FixedBytes<32>) -> Result<bool, ProviderError>

Source§

fn lowest_buffered_ancestor( &self, hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>

Source§

fn canonical_tip(&self) -> NumHash

Source§

fn pending_block_num_hash(&self) -> Option<NumHash>

Source§

fn pending_block_and_receipts(&self) -> Option<(SealedBlock, Vec<Receipt>)>

Source§

fn receipts_by_block_hash( &self, block_hash: FixedBytes<32>, ) -> Option<Vec<Receipt>>

§

impl<N, E> BlockchainTreeViewer for ShareableBlockchainTree<N, E>
where N: TreeNodeTypes, E: BlockExecutorProvider,

§

fn header_by_hash(&self, hash: FixedBytes<32>) -> Option<SealedHeader>

§

fn block_by_hash(&self, block_hash: FixedBytes<32>) -> Option<SealedBlock>

§

fn block_with_senders_by_hash( &self, block_hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>

§

fn buffered_header_by_hash( &self, block_hash: FixedBytes<32>, ) -> Option<SealedHeader>

§

fn is_canonical(&self, hash: FixedBytes<32>) -> Result<bool, ProviderError>

§

fn lowest_buffered_ancestor( &self, hash: FixedBytes<32>, ) -> Option<SealedBlockWithSenders>

§

fn canonical_tip(&self) -> NumHash

§

fn pending_block_num_hash(&self) -> Option<NumHash>

§

fn pending_block(&self) -> Option<SealedBlock>

§

fn pending_block_and_receipts(&self) -> Option<(SealedBlock, Vec<Receipt>)>

§

fn receipts_by_block_hash( &self, block_hash: FixedBytes<32>, ) -> Option<Vec<Receipt>>

Implementors§