reth_storage_api

Trait HeaderProvider

Source
pub trait HeaderProvider: Send + Sync {
    // Required methods
    fn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Header>>;
    fn header_by_number(&self, num: u64) -> ProviderResult<Option<Header>>;
    fn header_td(&self, hash: &BlockHash) -> ProviderResult<Option<U256>>;
    fn header_td_by_number(
        &self,
        number: BlockNumber,
    ) -> ProviderResult<Option<U256>>;
    fn headers_range(
        &self,
        range: impl RangeBounds<BlockNumber>,
    ) -> ProviderResult<Vec<Header>>;
    fn sealed_header(
        &self,
        number: BlockNumber,
    ) -> ProviderResult<Option<SealedHeader>>;
    fn sealed_headers_while(
        &self,
        range: impl RangeBounds<BlockNumber>,
        predicate: impl FnMut(&SealedHeader) -> bool,
    ) -> ProviderResult<Vec<SealedHeader>>;

    // Provided methods
    fn is_known(&self, block_hash: &BlockHash) -> ProviderResult<bool> { ... }
    fn sealed_header_by_hash(
        &self,
        block_hash: BlockHash,
    ) -> ProviderResult<Option<SealedHeader>> { ... }
    fn header_by_hash_or_number(
        &self,
        hash_or_num: BlockHashOrNumber,
    ) -> ProviderResult<Option<Header>> { ... }
    fn sealed_headers_range(
        &self,
        range: impl RangeBounds<BlockNumber>,
    ) -> ProviderResult<Vec<SealedHeader>> { ... }
}
Expand description

Client trait for fetching Header related data.

Required Methods§

Source

fn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Header>>

Get header by block hash

Source

fn header_by_number(&self, num: u64) -> ProviderResult<Option<Header>>

Get header by block number

Source

fn header_td(&self, hash: &BlockHash) -> ProviderResult<Option<U256>>

Get total difficulty by block hash.

Source

fn header_td_by_number( &self, number: BlockNumber, ) -> ProviderResult<Option<U256>>

Get total difficulty by block number.

Source

fn headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<Header>>

Get headers in range of block numbers

Source

fn sealed_header( &self, number: BlockNumber, ) -> ProviderResult<Option<SealedHeader>>

Get a single sealed header by block number.

Source

fn sealed_headers_while( &self, range: impl RangeBounds<BlockNumber>, predicate: impl FnMut(&SealedHeader) -> bool, ) -> ProviderResult<Vec<SealedHeader>>

Get sealed headers while predicate returns true or the range is exhausted.

Provided Methods§

Source

fn is_known(&self, block_hash: &BlockHash) -> ProviderResult<bool>

Check if block is known

Source

fn sealed_header_by_hash( &self, block_hash: BlockHash, ) -> ProviderResult<Option<SealedHeader>>

Retrieves the header sealed by the given block hash.

Source

fn header_by_hash_or_number( &self, hash_or_num: BlockHashOrNumber, ) -> ProviderResult<Option<Header>>

Get header by block number or hash

Source

fn sealed_headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<SealedHeader>>

Get headers in range of block numbers.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

fn is_known(&self, block_hash: &BlockHash) -> ProviderResult<bool>

Source§

fn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Header>>

Source§

fn sealed_header_by_hash( &self, block_hash: BlockHash, ) -> ProviderResult<Option<SealedHeader>>

Source§

fn header_by_number(&self, num: u64) -> ProviderResult<Option<Header>>

Source§

fn header_by_hash_or_number( &self, hash_or_num: BlockHashOrNumber, ) -> ProviderResult<Option<Header>>

Source§

fn header_td(&self, hash: &BlockHash) -> ProviderResult<Option<U256>>

Source§

fn header_td_by_number( &self, number: BlockNumber, ) -> ProviderResult<Option<U256>>

Source§

fn headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<Header>>

Source§

fn sealed_header( &self, number: BlockNumber, ) -> ProviderResult<Option<SealedHeader>>

Source§

fn sealed_headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<SealedHeader>>

Source§

fn sealed_headers_while( &self, range: impl RangeBounds<BlockNumber>, predicate: impl FnMut(&SealedHeader) -> bool, ) -> ProviderResult<Vec<SealedHeader>>

Source§

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

Source§

fn is_known(&self, block_hash: &BlockHash) -> ProviderResult<bool>

Source§

fn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Header>>

Source§

fn sealed_header_by_hash( &self, block_hash: BlockHash, ) -> ProviderResult<Option<SealedHeader>>

Source§

fn header_by_number(&self, num: u64) -> ProviderResult<Option<Header>>

Source§

fn header_by_hash_or_number( &self, hash_or_num: BlockHashOrNumber, ) -> ProviderResult<Option<Header>>

Source§

fn header_td(&self, hash: &BlockHash) -> ProviderResult<Option<U256>>

Source§

fn header_td_by_number( &self, number: BlockNumber, ) -> ProviderResult<Option<U256>>

Source§

fn headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<Header>>

Source§

fn sealed_header( &self, number: BlockNumber, ) -> ProviderResult<Option<SealedHeader>>

Source§

fn sealed_headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<SealedHeader>>

Source§

fn sealed_headers_while( &self, range: impl RangeBounds<BlockNumber>, predicate: impl FnMut(&SealedHeader) -> bool, ) -> ProviderResult<Vec<SealedHeader>>

Implementors§