reth_provider

Trait HeaderProvider

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

    // Required methods
    fn header(
        &self,
        block_hash: &FixedBytes<32>,
    ) -> Result<Option<Self::Header>, ProviderError>;
    fn header_by_number(
        &self,
        num: u64,
    ) -> Result<Option<Self::Header>, ProviderError>;
    fn header_td(
        &self,
        hash: &FixedBytes<32>,
    ) -> Result<Option<Uint<256, 4>>, ProviderError>;
    fn header_td_by_number(
        &self,
        number: u64,
    ) -> Result<Option<Uint<256, 4>>, ProviderError>;
    fn headers_range(
        &self,
        range: impl RangeBounds<u64>,
    ) -> Result<Vec<Self::Header>, ProviderError>;
    fn sealed_header(
        &self,
        number: u64,
    ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>;
    fn sealed_headers_while(
        &self,
        range: impl RangeBounds<u64>,
        predicate: impl FnMut(&SealedHeader<Self::Header>) -> bool,
    ) -> Result<Vec<SealedHeader<Self::Header>>, ProviderError>;

    // Provided methods
    fn is_known(
        &self,
        block_hash: &FixedBytes<32>,
    ) -> Result<bool, ProviderError> { ... }
    fn sealed_header_by_hash(
        &self,
        block_hash: FixedBytes<32>,
    ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError> { ... }
    fn header_by_hash_or_number(
        &self,
        hash_or_num: HashOrNumber,
    ) -> Result<Option<Self::Header>, ProviderError> { ... }
    fn sealed_headers_range(
        &self,
        range: impl RangeBounds<u64>,
    ) -> Result<Vec<SealedHeader<Self::Header>>, ProviderError> { ... }
}
Expand description

Client trait for fetching Header related data.

Required Associated Types§

type Header: BlockHeader

The header type this provider supports.

Required Methods§

fn header( &self, block_hash: &FixedBytes<32>, ) -> Result<Option<Self::Header>, ProviderError>

Get header by block hash

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

Get header by block number

fn header_td( &self, hash: &FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>

Get total difficulty by block hash.

fn header_td_by_number( &self, number: u64, ) -> Result<Option<Uint<256, 4>>, ProviderError>

Get total difficulty by block number.

fn headers_range( &self, range: impl RangeBounds<u64>, ) -> Result<Vec<Self::Header>, ProviderError>

Get headers in range of block numbers

fn sealed_header( &self, number: u64, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>

Get a single sealed header by block number.

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

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

Provided Methods§

fn is_known(&self, block_hash: &FixedBytes<32>) -> Result<bool, ProviderError>

Check if block is known

fn sealed_header_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<SealedHeader<Self::Header>>, ProviderError>

Retrieves the header sealed by the given block hash.

fn header_by_hash_or_number( &self, hash_or_num: HashOrNumber, ) -> Result<Option<Self::Header>, ProviderError>

Get header by block number or hash

fn sealed_headers_range( &self, range: impl RangeBounds<u64>, ) -> Result<Vec<SealedHeader<Self::Header>>, ProviderError>

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§

§

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

§

type Header = <T as HeaderProvider>::Header

§

fn is_known(&self, block_hash: &FixedBytes<32>) -> Result<bool, ProviderError>

§

fn header( &self, block_hash: &FixedBytes<32>, ) -> Result<Option<<&'a T as HeaderProvider>::Header>, ProviderError>

§

fn sealed_header_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<SealedHeader<<&'a T as HeaderProvider>::Header>>, ProviderError>

§

fn header_by_number( &self, num: u64, ) -> Result<Option<<&'a T as HeaderProvider>::Header>, ProviderError>

§

fn header_by_hash_or_number( &self, hash_or_num: HashOrNumber, ) -> Result<Option<<&'a T as HeaderProvider>::Header>, ProviderError>

§

fn header_td( &self, hash: &FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>

§

fn header_td_by_number( &self, number: u64, ) -> Result<Option<Uint<256, 4>>, ProviderError>

§

fn headers_range( &self, range: impl RangeBounds<u64>, ) -> Result<Vec<<&'a T as HeaderProvider>::Header>, ProviderError>

§

fn sealed_header( &self, number: u64, ) -> Result<Option<SealedHeader<<&'a T as HeaderProvider>::Header>>, ProviderError>

§

fn sealed_headers_range( &self, range: impl RangeBounds<u64>, ) -> Result<Vec<SealedHeader<<&'a T as HeaderProvider>::Header>>, ProviderError>

§

fn sealed_headers_while( &self, range: impl RangeBounds<u64>, predicate: impl FnMut(&SealedHeader<<&'a T as HeaderProvider>::Header>) -> bool, ) -> Result<Vec<SealedHeader<<&'a T as HeaderProvider>::Header>>, ProviderError>

§

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

§

type Header = <T as HeaderProvider>::Header

§

fn is_known(&self, block_hash: &FixedBytes<32>) -> Result<bool, ProviderError>

§

fn header( &self, block_hash: &FixedBytes<32>, ) -> Result<Option<<Arc<T> as HeaderProvider>::Header>, ProviderError>

§

fn sealed_header_by_hash( &self, block_hash: FixedBytes<32>, ) -> Result<Option<SealedHeader<<Arc<T> as HeaderProvider>::Header>>, ProviderError>

§

fn header_by_number( &self, num: u64, ) -> Result<Option<<Arc<T> as HeaderProvider>::Header>, ProviderError>

§

fn header_by_hash_or_number( &self, hash_or_num: HashOrNumber, ) -> Result<Option<<Arc<T> as HeaderProvider>::Header>, ProviderError>

§

fn header_td( &self, hash: &FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>

§

fn header_td_by_number( &self, number: u64, ) -> Result<Option<Uint<256, 4>>, ProviderError>

§

fn headers_range( &self, range: impl RangeBounds<u64>, ) -> Result<Vec<<Arc<T> as HeaderProvider>::Header>, ProviderError>

§

fn sealed_header( &self, number: u64, ) -> Result<Option<SealedHeader<<Arc<T> as HeaderProvider>::Header>>, ProviderError>

§

fn sealed_headers_range( &self, range: impl RangeBounds<u64>, ) -> Result<Vec<SealedHeader<<Arc<T> as HeaderProvider>::Header>>, ProviderError>

§

fn sealed_headers_while( &self, range: impl RangeBounds<u64>, predicate: impl FnMut(&SealedHeader<<Arc<T> as HeaderProvider>::Header>) -> bool, ) -> Result<Vec<SealedHeader<<Arc<T> as HeaderProvider>::Header>>, ProviderError>

Implementors§

Source§

impl HeaderProvider for MockEthProvider

Available on crate feature test-utils only.
Source§

type Header = Header

§

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

§

type Header = <N as NodePrimitives>::BlockHeader

Source§

impl<N: ProviderNodeTypes> HeaderProvider for BlockchainProvider2<N>

Source§

type Header = <<N as NodeTypes>::Primitives as NodePrimitives>::BlockHeader

Source§

impl<N: ProviderNodeTypes> HeaderProvider for ProviderFactory<N>

Source§

type Header = <<N as NodeTypes>::Primitives as NodePrimitives>::BlockHeader

Source§

impl<N: TreeNodeTypes> HeaderProvider for BlockchainProvider<N>

Source§

type Header = Header

Source§

impl<N: NodePrimitives<BlockHeader: Value>> HeaderProvider for StaticFileJarProvider<'_, N>

Source§

type Header = <N as NodePrimitives>::BlockHeader

Source§

impl<N: NodePrimitives<BlockHeader: Value>> HeaderProvider for StaticFileProvider<N>

Source§

type Header = <N as NodePrimitives>::BlockHeader

Source§

impl<TX: DbTx + 'static, N: NodeTypesForProvider> HeaderProvider for DatabaseProvider<TX, N>

Source§

type Header = <<N as NodeTypes>::Primitives as NodePrimitives>::BlockHeader