reth_provider

Trait HeaderProvider

pub trait HeaderProvider: Send + Sync {
    // Required methods
    fn header(
        &self,
        block_hash: &FixedBytes<32>,
    ) -> Result<Option<Header>, ProviderError>;
    fn header_by_number(
        &self,
        num: u64,
    ) -> Result<Option<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<Header>, ProviderError>;
    fn sealed_header(
        &self,
        number: u64,
    ) -> Result<Option<SealedHeader>, ProviderError>;
    fn sealed_headers_while(
        &self,
        range: impl RangeBounds<u64>,
        predicate: impl FnMut(&SealedHeader) -> bool,
    ) -> Result<Vec<SealedHeader>, 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>, ProviderError> { ... }
    fn header_by_hash_or_number(
        &self,
        hash_or_num: HashOrNumber,
    ) -> Result<Option<Header>, ProviderError> { ... }
    fn sealed_headers_range(
        &self,
        range: impl RangeBounds<u64>,
    ) -> Result<Vec<SealedHeader>, ProviderError> { ... }
}
Expand description

Client trait for fetching Header related data.

Required Methods§

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

Get header by block hash

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

Get headers in range of block numbers

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

Get a single sealed header by block number.

fn sealed_headers_while( &self, range: impl RangeBounds<u64>, predicate: impl FnMut(&SealedHeader) -> bool, ) -> Result<Vec<SealedHeader>, 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>, ProviderError>

Retrieves the header sealed by the given block hash.

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

Get header by block number or hash

fn sealed_headers_range( &self, range: impl RangeBounds<u64>, ) -> Result<Vec<SealedHeader>, 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,

§

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

§

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

§

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

§

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

§

fn header_by_hash_or_number( &self, hash_or_num: HashOrNumber, ) -> Result<Option<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<Header>, ProviderError>

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

fn header_by_hash_or_number( &self, hash_or_num: HashOrNumber, ) -> Result<Option<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<Header>, ProviderError>

§

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

§

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

§

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

Implementors§