reth_storage_api

Trait BlockNumReader

Source
pub trait BlockNumReader:
    BlockHashReader
    + Send
    + Sync {
    // Required methods
    fn chain_info(&self) -> ProviderResult<ChainInfo>;
    fn best_block_number(&self) -> ProviderResult<BlockNumber>;
    fn last_block_number(&self) -> ProviderResult<BlockNumber>;
    fn block_number(&self, hash: B256) -> ProviderResult<Option<BlockNumber>>;

    // Provided methods
    fn convert_hash_or_number(
        &self,
        id: BlockHashOrNumber,
    ) -> ProviderResult<Option<BlockNumber>> { ... }
    fn convert_number(
        &self,
        id: BlockHashOrNumber,
    ) -> ProviderResult<Option<B256>> { ... }
}
Expand description

Client trait for getting important block numbers (such as the latest block number), converting block hashes to numbers, and fetching a block hash from its block number.

This trait also supports fetching block hashes and block numbers from a [BlockHashOrNumber].

Required Methods§

Source

fn chain_info(&self) -> ProviderResult<ChainInfo>

Returns the current info for the chain.

Source

fn best_block_number(&self) -> ProviderResult<BlockNumber>

Returns the best block number in the chain.

Source

fn last_block_number(&self) -> ProviderResult<BlockNumber>

Returns the last block number associated with the last canonical header in the database.

Source

fn block_number(&self, hash: B256) -> ProviderResult<Option<BlockNumber>>

Gets the BlockNumber for the given hash. Returns None if no block with this hash exists.

Provided Methods§

Source

fn convert_hash_or_number( &self, id: BlockHashOrNumber, ) -> ProviderResult<Option<BlockNumber>>

Gets the block number for the given BlockHashOrNumber. Returns None if no block with this hash exists. If the BlockHashOrNumber is a Number, it is returned as is.

Source

fn convert_number(&self, id: BlockHashOrNumber) -> ProviderResult<Option<B256>>

Gets the block hash for the given BlockHashOrNumber. Returns None if no block with this number exists. If the BlockHashOrNumber is a Hash, it is returned as is.

Implementations on Foreign Types§

Source§

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

Source§

fn chain_info(&self) -> ProviderResult<ChainInfo>

Source§

fn best_block_number(&self) -> ProviderResult<BlockNumber>

Source§

fn last_block_number(&self) -> ProviderResult<BlockNumber>

Source§

fn block_number(&self, hash: B256) -> ProviderResult<Option<BlockNumber>>

Source§

fn convert_hash_or_number( &self, id: BlockHashOrNumber, ) -> ProviderResult<Option<BlockNumber>>

Source§

fn convert_number(&self, id: BlockHashOrNumber) -> ProviderResult<Option<B256>>

Source§

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

Source§

fn chain_info(&self) -> ProviderResult<ChainInfo>

Source§

fn best_block_number(&self) -> ProviderResult<BlockNumber>

Source§

fn last_block_number(&self) -> ProviderResult<BlockNumber>

Source§

fn block_number(&self, hash: B256) -> ProviderResult<Option<BlockNumber>>

Source§

fn convert_hash_or_number( &self, id: BlockHashOrNumber, ) -> ProviderResult<Option<BlockNumber>>

Source§

fn convert_number(&self, id: BlockHashOrNumber) -> ProviderResult<Option<B256>>

Implementors§

Source§

impl<ChainSpec: Send + Sync> BlockNumReader for NoopBlockReader<ChainSpec>