reth_storage_api

Trait BlockReaderIdExt

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

Source

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

Returns the block with the matching [BlockId] from the database.

Returns None if block is not found.

Source

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

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

Returns None if header is not found.

Source

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

Returns the header with the matching BlockId from the database.

Returns None if header is not found.

Source

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

Returns the ommers with the matching BlockId from the database.

Returns None if block is not found.

Provided Methods§

Source

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

Returns the block with matching tag from the database

Returns None if block is not found.

Source

fn pending_header(&self) -> ProviderResult<Option<SealedHeader<Self::Header>>>

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.

Source

fn latest_header(&self) -> ProviderResult<Option<SealedHeader<Self::Header>>>

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.

Source

fn safe_header(&self) -> ProviderResult<Option<SealedHeader<Self::Header>>>

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.

Source

fn finalized_header(&self) -> ProviderResult<Option<SealedHeader<Self::Header>>>

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.

Source

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

Returns the block with senders with matching [BlockId].

Returns the block’s transactions in the requested variant.

Returns None if block is not found.

Source

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

Returns the header with matching tag from the database

Returns None if header is not found.

Source

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

Returns the header with matching tag from the database

Returns None if header is not found.

Source

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

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§

Source§

impl<C: Send + Sync, N: NodePrimitives> BlockReaderIdExt for NoopProvider<C, N>