diff --git a/crates/storage/provider/src/providers/database/mod.rs b/crates/storage/provider/src/providers/database/mod.rs index 38f9879750..61762de4db 100644 --- a/crates/storage/provider/src/providers/database/mod.rs +++ b/crates/storage/provider/src/providers/database/mod.rs @@ -184,10 +184,6 @@ impl BlockProvider for ShareableDatabase { self.provider()?.pending_block() } - fn pending_header(&self) -> Result> { - self.provider()?.pending_header() - } - fn ommers(&self, id: BlockHashOrNumber) -> Result>> { self.provider()?.ommers(id) } diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index e52c903048..64dd88c0ad 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -206,10 +206,6 @@ impl<'this, TX: DbTx<'this>> BlockProvider for DatabaseProvider<'this, TX> { Ok(None) } - fn pending_header(&self) -> Result> { - Ok(None) - } - fn ommers(&self, id: BlockHashOrNumber) -> Result>> { if let Some(number) = self.convert_hash_or_number(id)? { // TODO: this can be optimized to return empty Vec post-merge diff --git a/crates/storage/provider/src/providers/mod.rs b/crates/storage/provider/src/providers/mod.rs index eb099a17b1..0915a72e5e 100644 --- a/crates/storage/provider/src/providers/mod.rs +++ b/crates/storage/provider/src/providers/mod.rs @@ -230,10 +230,6 @@ where Ok(self.tree.pending_block()) } - fn pending_header(&self) -> Result> { - Ok(self.tree.pending_header()) - } - fn ommers(&self, id: BlockHashOrNumber) -> Result>> { self.database.provider()?.ommers(id) } diff --git a/crates/storage/provider/src/test_utils/mock.rs b/crates/storage/provider/src/test_utils/mock.rs index a3b48578ec..a94e26a4f1 100644 --- a/crates/storage/provider/src/test_utils/mock.rs +++ b/crates/storage/provider/src/test_utils/mock.rs @@ -306,10 +306,6 @@ impl BlockProvider for MockEthProvider { Ok(None) } - fn pending_header(&self) -> Result> { - Ok(None) - } - fn ommers(&self, _id: BlockHashOrNumber) -> Result>> { Ok(None) } diff --git a/crates/storage/provider/src/test_utils/noop.rs b/crates/storage/provider/src/test_utils/noop.rs index bc0cf850d2..24310c620a 100644 --- a/crates/storage/provider/src/test_utils/noop.rs +++ b/crates/storage/provider/src/test_utils/noop.rs @@ -62,10 +62,6 @@ impl BlockProvider for NoopProvider { Ok(None) } - fn pending_header(&self) -> Result> { - Ok(None) - } - fn ommers(&self, _id: BlockHashOrNumber) -> Result>> { Ok(None) } diff --git a/crates/storage/provider/src/traits/block.rs b/crates/storage/provider/src/traits/block.rs index 4f15e4ea32..52c4de5d36 100644 --- a/crates/storage/provider/src/traits/block.rs +++ b/crates/storage/provider/src/traits/block.rs @@ -64,12 +64,6 @@ pub trait BlockProvider: /// and the caller does not know the hash. fn pending_block(&self) -> Result>; - /// Returns the pending block header if available - /// - /// Note: This returns a [SealedHeader] because it's expected that this is sealed by the - /// provider and the caller does not know the hash. - fn pending_header(&self) -> Result>; - /// Returns the ommers/uncle headers of the given block from the database. /// /// Returns `None` if block is not found. @@ -114,6 +108,38 @@ pub trait BlockProviderIdExt: BlockProvider + BlockIdProvider { self.convert_block_number(id)?.map_or_else(|| Ok(None), |num| self.block(num.into())) } + /// Returns the pending block header if available + /// + /// Note: This returns a [SealedHeader] because it's expected that this is sealed by the + /// provider and the caller does not know the hash. + fn pending_header(&self) -> Result> { + self.sealed_header_by_id(BlockNumberOrTag::Pending.into()) + } + + /// Returns the latest block header if available + /// + /// Note: This returns a [SealedHeader] because it's expected that this is sealed by the + /// provider and the caller does not know the hash. + fn latest_header(&self) -> Result> { + self.sealed_header_by_id(BlockNumberOrTag::Latest.into()) + } + + /// Returns the safe block header if available + /// + /// Note: This returns a [SealedHeader] because it's expected that this is sealed by the + /// provider and the caller does not know the hash. + fn safe_header(&self) -> Result> { + self.sealed_header_by_id(BlockNumberOrTag::Safe.into()) + } + + /// Returns the finalized block header if available + /// + /// Note: This returns a [SealedHeader] because it's expected that this is sealed by the + /// provider and the caller does not know the hash. + fn finalized_header(&self) -> Result> { + self.sealed_header_by_id(BlockNumberOrTag::Finalized.into()) + } + /// Returns the block with the matching `BlockId` from the database. /// /// Returns `None` if block is not found.