pub trait BlockHashReader: Send + Sync {
// Required methods
fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>;
fn canonical_hashes_range(
&self,
start: BlockNumber,
end: BlockNumber,
) -> ProviderResult<Vec<B256>>;
// Provided method
fn convert_block_hash(
&self,
hash_or_number: BlockHashOrNumber,
) -> ProviderResult<Option<B256>> { ... }
}
Expand description
Client trait for fetching block hashes by number.
Required Methods§
Sourcefn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>
fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>
Get the hash of the block with the given number. Returns None
if no block with this number
exists.
Sourcefn canonical_hashes_range(
&self,
start: BlockNumber,
end: BlockNumber,
) -> ProviderResult<Vec<B256>>
fn canonical_hashes_range( &self, start: BlockNumber, end: BlockNumber, ) -> ProviderResult<Vec<B256>>
Get headers in range of block hashes or numbers
Returns the available hashes of that range.
Note: The range is start..end
, so the expected result is [start..end)
Provided Methods§
Sourcefn convert_block_hash(
&self,
hash_or_number: BlockHashOrNumber,
) -> ProviderResult<Option<B256>>
fn convert_block_hash( &self, hash_or_number: BlockHashOrNumber, ) -> ProviderResult<Option<B256>>
Get the hash of the block with the given number. Returns None
if no block with this number
exists.
Implementations on Foreign Types§
Source§impl<'a, T: 'a + BlockHashReader + ?Sized> BlockHashReader for &'a T
impl<'a, T: 'a + BlockHashReader + ?Sized> BlockHashReader for &'a T
fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>
fn convert_block_hash( &self, hash_or_number: BlockHashOrNumber, ) -> ProviderResult<Option<B256>>
fn canonical_hashes_range( &self, start: BlockNumber, end: BlockNumber, ) -> ProviderResult<Vec<B256>>
Source§impl<T: BlockHashReader + ?Sized> BlockHashReader for Box<T>
impl<T: BlockHashReader + ?Sized> BlockHashReader for Box<T>
fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>
fn convert_block_hash( &self, hash_or_number: BlockHashOrNumber, ) -> ProviderResult<Option<B256>>
fn canonical_hashes_range( &self, start: BlockNumber, end: BlockNumber, ) -> ProviderResult<Vec<B256>>
Source§impl<T: BlockHashReader + ?Sized> BlockHashReader for Arc<T>
impl<T: BlockHashReader + ?Sized> BlockHashReader for Arc<T>
fn block_hash(&self, number: BlockNumber) -> ProviderResult<Option<B256>>
fn convert_block_hash( &self, hash_or_number: BlockHashOrNumber, ) -> ProviderResult<Option<B256>>
fn canonical_hashes_range( &self, start: BlockNumber, end: BlockNumber, ) -> ProviderResult<Vec<B256>>
Implementors§
impl<ChainSpec: Send + Sync, N: Send + Sync> BlockHashReader for NoopProvider<ChainSpec, N>
Noop implementation for testing purposes