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
type Header: BlockHeader
The header type this provider supports.
Required Methods§
fn header(
&self,
block_hash: &FixedBytes<32>,
) -> Result<Option<Self::Header>, ProviderError>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.