reth::providers

Trait BlockIdReader

pub trait BlockIdReader:
    BlockNumReader
    + Send
    + Sync {
    // Required methods
    fn pending_block_num_hash(&self) -> Result<Option<NumHash>, ProviderError>;
    fn safe_block_num_hash(&self) -> Result<Option<NumHash>, ProviderError>;
    fn finalized_block_num_hash(&self) -> Result<Option<NumHash>, ProviderError>;

    // Provided methods
    fn convert_block_number(
        &self,
        num: BlockNumberOrTag,
    ) -> Result<Option<u64>, ProviderError> { ... }
    fn block_hash_for_id(
        &self,
        block_id: BlockId,
    ) -> Result<Option<FixedBytes<32>>, ProviderError> { ... }
    fn block_number_for_id(
        &self,
        block_id: BlockId,
    ) -> Result<Option<u64>, ProviderError> { ... }
    fn safe_block_number(&self) -> Result<Option<u64>, ProviderError> { ... }
    fn finalized_block_number(&self) -> Result<Option<u64>, ProviderError> { ... }
    fn safe_block_hash(&self) -> Result<Option<FixedBytes<32>>, ProviderError> { ... }
    fn finalized_block_hash(
        &self,
    ) -> Result<Option<FixedBytes<32>>, ProviderError> { ... }
}
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§

fn pending_block_num_hash(&self) -> Result<Option<NumHash>, ProviderError>

Get the current pending block number and hash.

fn safe_block_num_hash(&self) -> Result<Option<NumHash>, ProviderError>

Get the current safe block number and hash.

fn finalized_block_num_hash(&self) -> Result<Option<NumHash>, ProviderError>

Get the current finalized block number and hash.

Provided Methods§

fn convert_block_number( &self, num: BlockNumberOrTag, ) -> Result<Option<u64>, ProviderError>

Converts the BlockNumberOrTag variants to a block number.

fn block_hash_for_id( &self, block_id: BlockId, ) -> Result<Option<FixedBytes<32>>, ProviderError>

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

fn block_number_for_id( &self, block_id: BlockId, ) -> Result<Option<u64>, ProviderError>

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

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

Get the safe block number.

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

Get the finalized block number.

fn safe_block_hash(&self) -> Result<Option<FixedBytes<32>>, ProviderError>

Get the safe block hash.

fn finalized_block_hash(&self) -> Result<Option<FixedBytes<32>>, ProviderError>

Get the finalized block hash.

Implementations on Foreign Types§

§

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

§

impl<T> BlockIdReader for Arc<T>

Implementors§