feat(rpc): impl filter changes (#1373)

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
Matthias Seitz
2023-02-17 18:02:36 +01:00
committed by GitHub
parent a0410e46b7
commit 26b606fda5
3 changed files with 176 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
use crate::{BlockNumber, H256};
use crate::{rpc::BlockNumber as RpcBlockNumber, BlockNumber, H256};
/// Current status of the blockchain's head.
#[derive(Default, Debug, Eq, PartialEq)]
@@ -12,3 +12,17 @@ pub struct ChainInfo {
/// 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: RpcBlockNumber) -> Option<u64> {
match number {
RpcBlockNumber::Finalized => self.last_finalized,
RpcBlockNumber::Safe => self.safe_finalized,
RpcBlockNumber::Earliest => Some(0),
RpcBlockNumber::Number(num) => Some(num.as_u64()),
RpcBlockNumber::Pending => None,
RpcBlockNumber::Latest => Some(self.best_number),
}
}
}