reth_storage_api

Trait BlockIdReader

Source
pub trait BlockIdReader:
    BlockNumReader
    + Send
    + Sync {
    // Required methods
    fn pending_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>;
    fn safe_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>;
    fn finalized_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>;

    // Provided methods
    fn convert_block_number(
        &self,
        num: BlockNumberOrTag,
    ) -> ProviderResult<Option<BlockNumber>> { ... }
    fn block_hash_for_id(
        &self,
        block_id: BlockId,
    ) -> ProviderResult<Option<B256>> { ... }
    fn block_number_for_id(
        &self,
        block_id: BlockId,
    ) -> ProviderResult<Option<BlockNumber>> { ... }
    fn safe_block_number(&self) -> ProviderResult<Option<BlockNumber>> { ... }
    fn finalized_block_number(&self) -> ProviderResult<Option<BlockNumber>> { ... }
    fn safe_block_hash(&self) -> ProviderResult<Option<B256>> { ... }
    fn finalized_block_hash(&self) -> ProviderResult<Option<B256>> { ... }
}
Expand description

Client trait for transforming [BlockId] into block numbers or hashes.

Types that implement this trait must be able to resolve all variants of [BlockNumberOrTag] to block numbers or hashes. Automatic implementations for resolving [BlockNumberOrTag] variants are provided if the type implements the pending_block_num_hash, finalized_block_num, and safe_block_num methods.

The resulting block numbers can be converted to hashes using the underlying BlockNumReader methods, and vice versa.

Required Methods§

Source

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

Get the current pending block number and hash.

Source

fn safe_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>

Get the current safe block number and hash.

Source

fn finalized_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>

Get the current finalized block number and hash.

Provided Methods§

Source

fn convert_block_number( &self, num: BlockNumberOrTag, ) -> ProviderResult<Option<BlockNumber>>

Converts the BlockNumberOrTag variants to a block number.

Source

fn block_hash_for_id(&self, block_id: BlockId) -> ProviderResult<Option<B256>>

Get the hash of the block by matching the given id.

Source

fn block_number_for_id( &self, block_id: BlockId, ) -> ProviderResult<Option<BlockNumber>>

Get the number of the block by matching the given id.

Source

fn safe_block_number(&self) -> ProviderResult<Option<BlockNumber>>

Get the safe block number.

Source

fn finalized_block_number(&self) -> ProviderResult<Option<BlockNumber>>

Get the finalized block number.

Source

fn safe_block_hash(&self) -> ProviderResult<Option<B256>>

Get the safe block hash.

Source

fn finalized_block_hash(&self) -> ProviderResult<Option<B256>>

Get the finalized block hash.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + BlockIdReader + ?Sized> BlockIdReader for &'a T

Source§

fn convert_block_number( &self, num: BlockNumberOrTag, ) -> ProviderResult<Option<BlockNumber>>

Source§

fn block_hash_for_id(&self, block_id: BlockId) -> ProviderResult<Option<B256>>

Source§

fn block_number_for_id( &self, block_id: BlockId, ) -> ProviderResult<Option<BlockNumber>>

Source§

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

Source§

fn safe_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>

Source§

fn finalized_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>

Source§

fn safe_block_number(&self) -> ProviderResult<Option<BlockNumber>>

Source§

fn finalized_block_number(&self) -> ProviderResult<Option<BlockNumber>>

Source§

fn safe_block_hash(&self) -> ProviderResult<Option<B256>>

Source§

fn finalized_block_hash(&self) -> ProviderResult<Option<B256>>

Source§

impl<T: BlockIdReader + ?Sized> BlockIdReader for Arc<T>
where Arc<T>: BlockNumReader + Send + Sync,

Source§

fn convert_block_number( &self, num: BlockNumberOrTag, ) -> ProviderResult<Option<BlockNumber>>

Source§

fn block_hash_for_id(&self, block_id: BlockId) -> ProviderResult<Option<B256>>

Source§

fn block_number_for_id( &self, block_id: BlockId, ) -> ProviderResult<Option<BlockNumber>>

Source§

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

Source§

fn safe_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>

Source§

fn finalized_block_num_hash(&self) -> ProviderResult<Option<BlockNumHash>>

Source§

fn safe_block_number(&self) -> ProviderResult<Option<BlockNumber>>

Source§

fn finalized_block_number(&self) -> ProviderResult<Option<BlockNumber>>

Source§

fn safe_block_hash(&self) -> ProviderResult<Option<B256>>

Source§

fn finalized_block_hash(&self) -> ProviderResult<Option<B256>>

Implementors§

Source§

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