pub trait BlockchainTreeViewer: Send + Sync {
Show 15 methods // Required methods fn header_by_hash(&self, hash: BlockHash) -> Option<SealedHeader>; fn block_by_hash(&self, hash: BlockHash) -> Option<SealedBlock>; fn block_with_senders_by_hash( &self, hash: BlockHash, ) -> Option<SealedBlockWithSenders>; fn buffered_header_by_hash( &self, block_hash: BlockHash, ) -> Option<SealedHeader>; fn is_canonical(&self, hash: BlockHash) -> Result<bool, ProviderError>; fn lowest_buffered_ancestor( &self, hash: BlockHash, ) -> Option<SealedBlockWithSenders>; fn canonical_tip(&self) -> BlockNumHash; fn pending_block_num_hash(&self) -> Option<BlockNumHash>; fn pending_block_and_receipts(&self) -> Option<(SealedBlock, Vec<Receipt>)>; fn receipts_by_block_hash( &self, block_hash: BlockHash, ) -> Option<Vec<Receipt>>; // Provided methods fn contains(&self, hash: BlockHash) -> 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

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§

source

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

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

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

source

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.

source

fn block_with_senders_by_hash( &self, hash: BlockHash, ) -> 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.

source

fn buffered_header_by_hash(&self, block_hash: BlockHash) -> 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.

source

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

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

source

fn lowest_buffered_ancestor( &self, hash: BlockHash, ) -> 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.

source

fn canonical_tip(&self) -> BlockNumHash

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

source

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

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

If there is no such block, this returns None.

source

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.

source

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

Returns the pending receipts if there is one.

Provided Methods§

source

fn contains(&self, hash: BlockHash) -> bool

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

source

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

Returns the pending block if there is one.

source

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

Returns the pending block if there is one.

source

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

Returns the pending receipts if there is one.

source

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

Returns the pending block if there is one.

Implementors§