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§
Required Methods§
Sourcefn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Self::Header>>
fn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Self::Header>>
Get header by block hash
Sourcefn header_by_number(&self, num: u64) -> ProviderResult<Option<Self::Header>>
fn header_by_number(&self, num: u64) -> ProviderResult<Option<Self::Header>>
Get header by block number
Sourcefn header_td(&self, hash: &BlockHash) -> ProviderResult<Option<U256>>
fn header_td(&self, hash: &BlockHash) -> ProviderResult<Option<U256>>
Get total difficulty by block hash.
Sourcefn header_td_by_number(
&self,
number: BlockNumber,
) -> ProviderResult<Option<U256>>
fn header_td_by_number( &self, number: BlockNumber, ) -> ProviderResult<Option<U256>>
Get total difficulty by block number.
Sourcefn headers_range(
&self,
range: impl RangeBounds<BlockNumber>,
) -> ProviderResult<Vec<Self::Header>>
fn headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<Self::Header>>
Get headers in range of block numbers
Sourcefn sealed_header(
&self,
number: BlockNumber,
) -> ProviderResult<Option<SealedHeader<Self::Header>>>
fn sealed_header( &self, number: BlockNumber, ) -> ProviderResult<Option<SealedHeader<Self::Header>>>
Get a single sealed header by block number.
Sourcefn sealed_headers_while(
&self,
range: impl RangeBounds<BlockNumber>,
predicate: impl FnMut(&SealedHeader<Self::Header>) -> bool,
) -> ProviderResult<Vec<SealedHeader<Self::Header>>>
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§
Sourcefn is_known(&self, block_hash: &BlockHash) -> ProviderResult<bool>
fn is_known(&self, block_hash: &BlockHash) -> ProviderResult<bool>
Check if block is known
Sourcefn sealed_header_by_hash(
&self,
block_hash: BlockHash,
) -> ProviderResult<Option<SealedHeader<Self::Header>>>
fn sealed_header_by_hash( &self, block_hash: BlockHash, ) -> ProviderResult<Option<SealedHeader<Self::Header>>>
Retrieves the header sealed by the given block hash.
Sourcefn header_by_hash_or_number(
&self,
hash_or_num: BlockHashOrNumber,
) -> ProviderResult<Option<Self::Header>>
fn header_by_hash_or_number( &self, hash_or_num: BlockHashOrNumber, ) -> ProviderResult<Option<Self::Header>>
Get header by block number or hash
Sourcefn sealed_headers_range(
&self,
range: impl RangeBounds<BlockNumber>,
) -> ProviderResult<Vec<SealedHeader<Self::Header>>>
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.