diff --git a/crates/storage/provider/src/providers/chain_info.rs b/crates/storage/provider/src/providers/chain_info.rs index a1a8977817..5e65358108 100644 --- a/crates/storage/provider/src/providers/chain_info.rs +++ b/crates/storage/provider/src/providers/chain_info.rs @@ -1,5 +1,5 @@ use parking_lot::RwLock; -use reth_primitives::{BlockNumHash, SealedHeader}; +use reth_primitives::{BlockNumHash, ChainInfo, SealedHeader}; use std::{sync::Arc, time::Instant}; /// Tracks the chain info: canonical head, safe block, finalized block. @@ -21,6 +21,12 @@ impl ChainInfoTracker { } } + /// Returns the [ChainInfo] for the canonical head. + pub(crate) fn chain_info(&self) -> ChainInfo { + let inner = self.inner.canonical_head.read(); + ChainInfo { best_hash: inner.hash(), best_number: inner.number } + } + /// Update the timestamp when we received a forkchoice update. pub(crate) fn on_forkchoice_update_received(&self) { self.inner.last_forkchoice_update.write().replace(Instant::now()); diff --git a/crates/storage/provider/src/providers/mod.rs b/crates/storage/provider/src/providers/mod.rs index cc3b0bec8b..29fd8bdeb6 100644 --- a/crates/storage/provider/src/providers/mod.rs +++ b/crates/storage/provider/src/providers/mod.rs @@ -120,7 +120,7 @@ where Tree: BlockchainTreeViewer + Send + Sync, { fn chain_info(&self) -> Result { - self.database.chain_info() + Ok(self.chain_info.chain_info()) } fn best_block_number(&self) -> Result {