reth::providers

Trait BlockReaderIdExt

pub trait BlockReaderIdExt: BlockReader + ReceiptProviderIdExt {
Show 13 methods // Required methods fn block_by_id( &self, id: BlockId, ) -> Result<Option<Self::Block>, ProviderError>; fn sealed_header_by_id( &self, id: BlockId, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>; fn header_by_id( &self, id: BlockId, ) -> Result<Option<Self::Header>, ProviderError>; fn ommers_by_id( &self, id: BlockId, ) -> Result<Option<Vec<Self::Header>>, ProviderError>; // Provided methods fn block_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Self::Block>, ProviderError> { ... } fn pending_header( &self, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError> { ... } fn latest_header( &self, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError> { ... } fn safe_header( &self, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError> { ... } fn finalized_header( &self, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError> { ... } fn block_with_senders_by_id( &self, id: BlockId, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders<Self::Block>>, ProviderError> { ... } fn header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Self::Header>, ProviderError> { ... } fn sealed_header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError> { ... } fn ommers_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Vec<Self::Header>>, ProviderError> { ... }
}
Expand description

Trait extension for BlockReader, for types that implement BlockId conversion.

The BlockReader trait should be implemented on types that can retrieve a block from either a block number or hash. However, it might be desirable to fetch a block from a BlockId type, which can be a number, hash, or tag such as BlockNumberOrTag::Safe.

Resolving tags requires keeping track of block hashes or block numbers associated with the tag, so this trait can only be implemented for types that implement BlockIdReader. The BlockIdReader methods should be used to resolve BlockIds to block numbers or hashes, and retrieving the block should be done using the type’s BlockReader methods.

Required Methods§

fn block_by_id(&self, id: BlockId) -> Result<Option<Self::Block>, ProviderError>

Returns the block with the matching BlockId from the database.

Returns None if block is not found.

fn sealed_header_by_id( &self, id: BlockId, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>

Returns the sealed header with the matching BlockId from the database.

Returns None if header is not found.

fn header_by_id( &self, id: BlockId, ) -> Result<Option<Self::Header>, ProviderError>

Returns the header with the matching BlockId from the database.

Returns None if header is not found.

fn ommers_by_id( &self, id: BlockId, ) -> Result<Option<Vec<Self::Header>>, ProviderError>

Returns the ommers with the matching BlockId from the database.

Returns None if block is not found.

Provided Methods§

fn block_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Self::Block>, ProviderError>

Returns the block with matching tag from the database

Returns None if block is not found.

fn pending_header( &self, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>

Returns the pending block header if available

Note: This returns a SealedHeader because it’s expected that this is sealed by the provider and the caller does not know the hash.

fn latest_header( &self, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>

Returns the latest block header if available

Note: This returns a SealedHeader because it’s expected that this is sealed by the provider and the caller does not know the hash.

fn safe_header( &self, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>

Returns the safe block header if available

Note: This returns a SealedHeader because it’s expected that this is sealed by the provider and the caller does not know the hash.

fn finalized_header( &self, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>

Returns the finalized block header if available

Note: This returns a SealedHeader because it’s expected that this is sealed by the provider and the caller does not know the hash.

fn block_with_senders_by_id( &self, id: BlockId, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders<Self::Block>>, ProviderError>

Returns the block with senders with matching BlockId.

Returns the block’s transactions in the requested variant.

Returns None if block is not found.

fn header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Self::Header>, ProviderError>

Returns the header with matching tag from the database

Returns None if header is not found.

fn sealed_header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>

Returns the header with matching tag from the database

Returns None if header is not found.

fn ommers_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Vec<Self::Header>>, ProviderError>

Returns the ommers with the matching tag from the database.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§