mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: use BlockHashOrNum in providers (#2627)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::{BlockNumber, BlockNumberOrTag, H256};
|
||||
use crate::{BlockNumber, H256};
|
||||
|
||||
/// Current status of the blockchain's head.
|
||||
#[derive(Default, Clone, Debug, Eq, PartialEq)]
|
||||
@ -7,22 +7,4 @@ pub struct ChainInfo {
|
||||
pub best_hash: H256,
|
||||
/// The block number of the highest fully synced block.
|
||||
pub best_number: BlockNumber,
|
||||
/// Last block that was finalized.
|
||||
pub last_finalized: Option<BlockNumber>,
|
||||
/// Safe block
|
||||
pub safe_finalized: Option<BlockNumber>,
|
||||
}
|
||||
|
||||
impl ChainInfo {
|
||||
/// Attempts to convert a [BlockNumber](crate::rpc::BlockNumber) enum to a numeric value
|
||||
pub fn convert_block_number(&self, number: BlockNumberOrTag) -> Option<u64> {
|
||||
match number {
|
||||
BlockNumberOrTag::Finalized => self.last_finalized,
|
||||
BlockNumberOrTag::Safe => self.safe_finalized,
|
||||
BlockNumberOrTag::Earliest => Some(0),
|
||||
BlockNumberOrTag::Number(num) => Some(num),
|
||||
BlockNumberOrTag::Pending => None,
|
||||
BlockNumberOrTag::Latest => Some(self.best_number),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user