reth_storage_api

Trait HeaderProvider

Source
pub trait HeaderProvider: Send + Sync {
    type Header: BlockHeader;

    // Required methods
    fn header(
        &self,
        block_hash: &BlockHash,
    ) -> ProviderResult<Option<Self::Header>>;
    fn header_by_number(&self, num: u64) -> ProviderResult<Option<Self::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<Self::Header>>;
    fn sealed_header(
        &self,
        number: BlockNumber,
    ) -> ProviderResult<Option<SealedHeader<Self::Header>>>;
    fn sealed_headers_while(
        &self,
        range: impl RangeBounds<BlockNumber>,
        predicate: impl FnMut(&SealedHeader<Self::Header>) -> bool,
    ) -> ProviderResult<Vec<SealedHeader<Self::Header>>>;

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

Client trait for fetching Header related data.

Required Associated Types§

Source

type Header: BlockHeader

The header type this provider supports.

Required Methods§

Source

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

Get header by block hash

Source

fn header_by_number(&self, num: u64) -> ProviderResult<Option<Self::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<Self::Header>>

Get headers in range of block numbers

Source

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

Get a single sealed header by block number.

Source

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

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<Self::Header>>>

Retrieves the header sealed by the given block hash.

Source

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

Get header by block number or hash

Source

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

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§

type Header = <T as HeaderProvider>::Header

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn header_by_hash_or_number( &self, hash_or_num: BlockHashOrNumber, ) -> ProviderResult<Option<Self::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<Self::Header>>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Header = <T as HeaderProvider>::Header

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn header_by_hash_or_number( &self, hash_or_num: BlockHashOrNumber, ) -> ProviderResult<Option<Self::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<Self::Header>>

Source§

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

Source§

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

Source§

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

Implementors§

Source§

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

Source§

type Header = <N as NodePrimitives>::BlockHeader