pub trait HeaderProvider: Send + Sync {
// Required methods
fn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Header>>;
fn header_by_number(&self, num: u64) -> ProviderResult<Option<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<Header>>;
fn sealed_header(
&self,
number: BlockNumber,
) -> ProviderResult<Option<SealedHeader>>;
fn sealed_headers_while(
&self,
range: impl RangeBounds<BlockNumber>,
predicate: impl FnMut(&SealedHeader) -> bool,
) -> ProviderResult<Vec<SealedHeader>>;
// Provided methods
fn is_known(&self, block_hash: &BlockHash) -> ProviderResult<bool> { ... }
fn sealed_header_by_hash(
&self,
block_hash: BlockHash,
) -> ProviderResult<Option<SealedHeader>> { ... }
fn header_by_hash_or_number(
&self,
hash_or_num: BlockHashOrNumber,
) -> ProviderResult<Option<Header>> { ... }
fn sealed_headers_range(
&self,
range: impl RangeBounds<BlockNumber>,
) -> ProviderResult<Vec<SealedHeader>> { ... }
}
Expand description
Client trait for fetching Header
related data.
Required Methods§
Sourcefn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Header>>
fn header(&self, block_hash: &BlockHash) -> ProviderResult<Option<Header>>
Get header by block hash
Sourcefn header_by_number(&self, num: u64) -> ProviderResult<Option<Header>>
fn header_by_number(&self, num: u64) -> ProviderResult<Option<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<Header>>
fn headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<Header>>
Get headers in range of block numbers
Sourcefn sealed_header(
&self,
number: BlockNumber,
) -> ProviderResult<Option<SealedHeader>>
fn sealed_header( &self, number: BlockNumber, ) -> ProviderResult<Option<SealedHeader>>
Get a single sealed header by block number.
Sourcefn sealed_headers_while(
&self,
range: impl RangeBounds<BlockNumber>,
predicate: impl FnMut(&SealedHeader) -> bool,
) -> ProviderResult<Vec<SealedHeader>>
fn sealed_headers_while( &self, range: impl RangeBounds<BlockNumber>, predicate: impl FnMut(&SealedHeader) -> bool, ) -> ProviderResult<Vec<SealedHeader>>
Get sealed headers while predicate
returns true
or the range is exhausted.
Provided Methods§
Sourcefn sealed_header_by_hash(
&self,
block_hash: BlockHash,
) -> ProviderResult<Option<SealedHeader>>
fn sealed_header_by_hash( &self, block_hash: BlockHash, ) -> ProviderResult<Option<SealedHeader>>
Retrieves the header sealed by the given block hash.
Sourcefn header_by_hash_or_number(
&self,
hash_or_num: BlockHashOrNumber,
) -> ProviderResult<Option<Header>>
fn header_by_hash_or_number( &self, hash_or_num: BlockHashOrNumber, ) -> ProviderResult<Option<Header>>
Get header by block number or hash
Sourcefn sealed_headers_range(
&self,
range: impl RangeBounds<BlockNumber>,
) -> ProviderResult<Vec<SealedHeader>>
fn sealed_headers_range( &self, range: impl RangeBounds<BlockNumber>, ) -> ProviderResult<Vec<SealedHeader>>
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.