pub trait BlockNumReader:
BlockHashReader
+ Send
+ Sync {
// Required methods
fn chain_info(&self) -> ProviderResult<ChainInfo>;
fn best_block_number(&self) -> ProviderResult<BlockNumber>;
fn last_block_number(&self) -> ProviderResult<BlockNumber>;
fn block_number(&self, hash: B256) -> ProviderResult<Option<BlockNumber>>;
// Provided methods
fn convert_hash_or_number(
&self,
id: BlockHashOrNumber,
) -> ProviderResult<Option<BlockNumber>> { ... }
fn convert_number(
&self,
id: BlockHashOrNumber,
) -> ProviderResult<Option<B256>> { ... }
}
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§
Sourcefn chain_info(&self) -> ProviderResult<ChainInfo>
fn chain_info(&self) -> ProviderResult<ChainInfo>
Returns the current info for the chain.
Sourcefn best_block_number(&self) -> ProviderResult<BlockNumber>
fn best_block_number(&self) -> ProviderResult<BlockNumber>
Returns the best block number in the chain.
Sourcefn last_block_number(&self) -> ProviderResult<BlockNumber>
fn last_block_number(&self) -> ProviderResult<BlockNumber>
Returns the last block number associated with the last canonical header in the database.
Sourcefn block_number(&self, hash: B256) -> ProviderResult<Option<BlockNumber>>
fn block_number(&self, hash: B256) -> ProviderResult<Option<BlockNumber>>
Gets the BlockNumber
for the given hash. Returns None
if no block with this hash exists.
Provided Methods§
Sourcefn convert_hash_or_number(
&self,
id: BlockHashOrNumber,
) -> ProviderResult<Option<BlockNumber>>
fn convert_hash_or_number( &self, id: BlockHashOrNumber, ) -> ProviderResult<Option<BlockNumber>>
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.
Sourcefn convert_number(&self, id: BlockHashOrNumber) -> ProviderResult<Option<B256>>
fn convert_number(&self, id: BlockHashOrNumber) -> ProviderResult<Option<B256>>
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.