Trait BlockNumReader
pub trait BlockNumReader:
BlockHashReader
+ Send
+ Sync {
// Required methods
fn chain_info(&self) -> Result<ChainInfo, ProviderError>;
fn best_block_number(&self) -> Result<u64, ProviderError>;
fn last_block_number(&self) -> Result<u64, ProviderError>;
fn block_number(
&self,
hash: FixedBytes<32>,
) -> Result<Option<u64>, ProviderError>;
// Provided methods
fn convert_hash_or_number(
&self,
id: HashOrNumber,
) -> Result<Option<u64>, ProviderError> { ... }
fn convert_number(
&self,
id: HashOrNumber,
) -> Result<Option<FixedBytes<32>>, ProviderError> { ... }
}
Expand description
Client trait for getting important block numbers (such as the latest block number), converting block hashes to numbers, and fetching a block hash from its block number.
This trait also supports fetching block hashes and block numbers from a [BlockHashOrNumber].
Required Methods§
fn chain_info(&self) -> Result<ChainInfo, ProviderError>
fn chain_info(&self) -> Result<ChainInfo, ProviderError>
Returns the current info for the chain.
fn best_block_number(&self) -> Result<u64, ProviderError>
fn best_block_number(&self) -> Result<u64, ProviderError>
Returns the best block number in the chain.
fn last_block_number(&self) -> Result<u64, ProviderError>
fn last_block_number(&self) -> Result<u64, ProviderError>
Returns the last block number associated with the last canonical header in the database.
fn block_number(
&self,
hash: FixedBytes<32>,
) -> Result<Option<u64>, ProviderError>
fn block_number( &self, hash: FixedBytes<32>, ) -> Result<Option<u64>, ProviderError>
Gets the BlockNumber
for the given hash. Returns None
if no block with this hash exists.
Provided Methods§
fn convert_hash_or_number(
&self,
id: HashOrNumber,
) -> Result<Option<u64>, ProviderError>
fn convert_hash_or_number( &self, id: HashOrNumber, ) -> Result<Option<u64>, ProviderError>
Gets the block number for the given BlockHashOrNumber
. Returns None
if no block with
this hash exists. If the BlockHashOrNumber
is a Number
, it is returned as is.
fn convert_number(
&self,
id: HashOrNumber,
) -> Result<Option<FixedBytes<32>>, ProviderError>
fn convert_number( &self, id: HashOrNumber, ) -> Result<Option<FixedBytes<32>>, ProviderError>
Gets the block hash for the given BlockHashOrNumber
. Returns None
if no block with this
number exists. If the BlockHashOrNumber
is a Hash
, it is returned as is.
Implementations on Foreign Types§
§impl<'a, T> BlockNumReader for &'a T
impl<'a, T> BlockNumReader for &'a T
fn chain_info(&self) -> Result<ChainInfo, ProviderError>
fn best_block_number(&self) -> Result<u64, ProviderError>
fn last_block_number(&self) -> Result<u64, ProviderError>
fn block_number( &self, hash: FixedBytes<32>, ) -> Result<Option<u64>, ProviderError>
fn convert_hash_or_number( &self, id: HashOrNumber, ) -> Result<Option<u64>, ProviderError>
fn convert_number( &self, id: HashOrNumber, ) -> Result<Option<FixedBytes<32>>, ProviderError>
§impl<T> BlockNumReader for Arc<T>
impl<T> BlockNumReader for Arc<T>
fn chain_info(&self) -> Result<ChainInfo, ProviderError>
fn best_block_number(&self) -> Result<u64, ProviderError>
fn last_block_number(&self) -> Result<u64, ProviderError>
fn block_number( &self, hash: FixedBytes<32>, ) -> Result<Option<u64>, ProviderError>
fn convert_hash_or_number( &self, id: HashOrNumber, ) -> Result<Option<u64>, ProviderError>
fn convert_number( &self, id: HashOrNumber, ) -> Result<Option<FixedBytes<32>>, ProviderError>
Implementors§
impl BlockNumReader for StaticFileJarProvider<'_>
impl BlockNumReader for StaticFileProvider
impl BlockNumReader for MockEthProvider
test-utils
only.impl BlockNumReader for NoopProvider
test-utils
only.