BlockIdReader

Trait BlockIdReader 

Source
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> { ... }
}
Available on crate feature storage-api only.
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) -> Result<Option<NumHash>, ProviderError>

Get the current pending block number and hash.

Source

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

Get the current safe block number and hash.

Source

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

Get the current finalized block number and hash.

Provided Methods§

Source

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

Converts the BlockNumberOrTag variants to a block number.

Source

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.

Source

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

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

Source

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

Get the safe block number.

Source

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

Get the finalized block number.

Source

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

Get the safe block hash.

Source

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

Get the finalized block hash.

Implementations on Foreign Types§

Source§

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

Source§

impl<T> BlockIdReader for Arc<T>

Implementors§

Source§

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

Source§

impl<N> BlockIdReader for BlockchainProvider<N>

Source§

impl<T, ChainSpec> BlockIdReader for MockEthProvider<T, ChainSpec>
where T: NodePrimitives, ChainSpec: EthChainSpec + Send + Sync + 'static,