reth_storage_api

Trait BlockHashReader

Source
pub trait BlockHashReader: Send + Sync {
    // Required methods
    fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>;
    fn canonical_hashes_range(
        &self,
        start: BlockNumber,
        end: BlockNumber,
    ) -> ProviderResult<Vec<B256>>;

    // Provided method
    fn convert_block_hash(
        &self,
        hash_or_number: BlockHashOrNumber,
    ) -> ProviderResult<Option<B256>> { ... }
}
Expand description

Client trait for fetching block hashes by number.

Required Methods§

Source

fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>

Get the hash of the block with the given number. Returns None if no block with this number exists.

Source

fn canonical_hashes_range( &self, start: BlockNumber, end: BlockNumber, ) -> ProviderResult<Vec<B256>>

Get headers in range of block hashes or numbers

Returns the available hashes of that range.

Note: The range is start..end, so the expected result is [start..end)

Provided Methods§

Source

fn convert_block_hash( &self, hash_or_number: BlockHashOrNumber, ) -> ProviderResult<Option<B256>>

Get the hash of the block with the given number. Returns None if no block with this number exists.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + BlockHashReader + ?Sized> BlockHashReader for &'a T
where &'a T: Send + Sync,

Source§

fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>

Source§

fn convert_block_hash( &self, hash_or_number: BlockHashOrNumber, ) -> ProviderResult<Option<B256>>

Source§

fn canonical_hashes_range( &self, start: BlockNumber, end: BlockNumber, ) -> ProviderResult<Vec<B256>>

Source§

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

Source§

fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>

Source§

fn convert_block_hash( &self, hash_or_number: BlockHashOrNumber, ) -> ProviderResult<Option<B256>>

Source§

fn canonical_hashes_range( &self, start: BlockNumber, end: BlockNumber, ) -> ProviderResult<Vec<B256>>

Source§

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

Source§

fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>

Source§

fn convert_block_hash( &self, hash_or_number: BlockHashOrNumber, ) -> ProviderResult<Option<B256>>

Source§

fn canonical_hashes_range( &self, start: BlockNumber, end: BlockNumber, ) -> ProviderResult<Vec<B256>>

Implementors§

Source§

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

Noop implementation for testing purposes