reth_provider

Trait BlockNumReader

pub trait BlockNumReader:
    BlockHashReader
    + Send
    + Sync {
    // Required methods
    fn chain_info(&self) -> Result<ChainInfo, ProviderError>;
    fn best_block_number(&self) -> Result<u64, ProviderError>;
    fn last_block_number(&self) -> Result<u64, ProviderError>;
    fn block_number(
        &self,
        hash: FixedBytes<32>,
    ) -> Result<Option<u64>, ProviderError>;

    // Provided methods
    fn convert_hash_or_number(
        &self,
        id: HashOrNumber,
    ) -> Result<Option<u64>, ProviderError> { ... }
    fn convert_number(
        &self,
        id: HashOrNumber,
    ) -> Result<Option<FixedBytes<32>>, ProviderError> { ... }
}
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§

fn chain_info(&self) -> Result<ChainInfo, ProviderError>

Returns the current info for the chain.

fn best_block_number(&self) -> Result<u64, ProviderError>

Returns the best block number in the chain.

fn last_block_number(&self) -> Result<u64, ProviderError>

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

fn block_number( &self, hash: FixedBytes<32>, ) -> Result<Option<u64>, ProviderError>

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

Provided Methods§

fn convert_hash_or_number( &self, id: HashOrNumber, ) -> Result<Option<u64>, ProviderError>

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.

fn convert_number( &self, id: HashOrNumber, ) -> Result<Option<FixedBytes<32>>, ProviderError>

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§

§

impl<'a, T> BlockNumReader for &'a T

§

fn chain_info(&self) -> Result<ChainInfo, ProviderError>

§

fn best_block_number(&self) -> Result<u64, ProviderError>

§

fn last_block_number(&self) -> Result<u64, ProviderError>

§

fn block_number( &self, hash: FixedBytes<32>, ) -> Result<Option<u64>, ProviderError>

§

fn convert_hash_or_number( &self, id: HashOrNumber, ) -> Result<Option<u64>, ProviderError>

§

fn convert_number( &self, id: HashOrNumber, ) -> Result<Option<FixedBytes<32>>, ProviderError>

§

impl<T> BlockNumReader for Arc<T>

§

fn chain_info(&self) -> Result<ChainInfo, ProviderError>

§

fn best_block_number(&self) -> Result<u64, ProviderError>

§

fn last_block_number(&self) -> Result<u64, ProviderError>

§

fn block_number( &self, hash: FixedBytes<32>, ) -> Result<Option<u64>, ProviderError>

§

fn convert_hash_or_number( &self, id: HashOrNumber, ) -> Result<Option<u64>, ProviderError>

§

fn convert_number( &self, id: HashOrNumber, ) -> Result<Option<FixedBytes<32>>, ProviderError>

Implementors§

Source§

impl BlockNumReader for MockEthProvider

Available on crate feature test-utils only.
Source§

impl BlockNumReader for NoopProvider

Available on crate feature test-utils only.
§

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

Source§

impl<N: ProviderNodeTypes> BlockNumReader for BlockchainProvider2<N>

Source§

impl<N: ProviderNodeTypes> BlockNumReader for BlockchainProvider<N>

Source§

impl<N: ProviderNodeTypes> BlockNumReader for ConsistentProvider<N>

Source§

impl<N: ProviderNodeTypes> BlockNumReader for ProviderFactory<N>

Source§

impl<N: NodePrimitives> BlockNumReader for StaticFileJarProvider<'_, N>

Source§

impl<N: NodePrimitives> BlockNumReader for StaticFileProvider<N>

Source§

impl<TX: DbTx + 'static, N: NodeTypes> BlockNumReader for DatabaseProvider<TX, N>