diff --git a/crates/consensus/src/header.rs b/crates/consensus/src/header.rs index 91f17b797af..f593b873929 100644 --- a/crates/consensus/src/header.rs +++ b/crates/consensus/src/header.rs @@ -1,9 +1,10 @@ -use crate::Sealable; use alloy_eips::{ eip1559::{calc_next_block_base_fee, BaseFeeParams}, eip4844::{calc_blob_gasprice, calc_excess_blob_gas}, }; -use alloy_primitives::{b256, keccak256, Address, BlockNumber, Bloom, Bytes, B256, B64, U256}; +use alloy_primitives::{ + b256, keccak256, Address, BlockNumber, Bloom, Bytes, Sealable, B256, B64, U256, +}; use alloy_rlp::{ length_of_length, Buf, BufMut, Decodable, Encodable, EMPTY_LIST_CODE, EMPTY_STRING_CODE, }; @@ -161,7 +162,7 @@ impl Default for Header { } impl Sealable for Header { - fn hash(&self) -> B256 { + fn hash_slow(&self) -> B256 { self.hash_slow() } } diff --git a/crates/consensus/src/lib.rs b/crates/consensus/src/lib.rs index da2e1cb1dcc..5cef218eab9 100644 --- a/crates/consensus/src/lib.rs +++ b/crates/consensus/src/lib.rs @@ -42,8 +42,7 @@ pub use alloy_eips::eip4844::{ #[cfg(feature = "kzg")] pub use alloy_eips::eip4844::env_settings::EnvKzgSettings; -mod sealed; -pub use sealed::{Sealable, Sealed}; +pub use alloy_primitives::{Sealable, Sealed}; mod signed; pub use signed::Signed; diff --git a/crates/consensus/src/receipt/receipts.rs b/crates/consensus/src/receipt/receipts.rs index f57e648c3e4..e9476a81f72 100644 --- a/crates/consensus/src/receipt/receipts.rs +++ b/crates/consensus/src/receipt/receipts.rs @@ -107,7 +107,7 @@ impl From> for Receipt { /// This convenience type allows us to lazily calculate the bloom filter for a /// receipt, similar to [`Sealed`]. /// -/// [`Sealed`]: crate::sealed::Sealed +/// [`Sealed`]: crate::Sealed #[derive(Clone, Debug, Default, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] diff --git a/crates/consensus/src/sealed.rs b/crates/consensus/src/sealed.rs deleted file mode 100644 index 9db492d7523..00000000000 --- a/crates/consensus/src/sealed.rs +++ /dev/null @@ -1,67 +0,0 @@ -use alloy_primitives::B256; - -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -/// A consensus hashable item, with its memoized hash. -/// -/// We do not implement -pub struct Sealed { - /// The inner item - inner: T, - /// Its hash. - seal: B256, -} - -impl core::ops::Deref for Sealed { - type Target = T; - - fn deref(&self) -> &Self::Target { - self.inner() - } -} - -impl Sealed { - /// Instantiate without performing the hash. This should be used carefully. - pub const fn new_unchecked(inner: T, seal: B256) -> Self { - Self { inner, seal } - } - - /// Decompose into parts. - pub fn into_parts(self) -> (T, B256) { - (self.inner, self.seal) - } - - /// Get the inner item. - #[inline(always)] - pub const fn inner(&self) -> &T { - &self.inner - } - - /// Get the hash. - #[inline(always)] - pub const fn seal(&self) -> B256 { - self.seal - } - - /// Geth the hash (alias for [`Self::seal`]). - #[inline(always)] - pub const fn hash(&self) -> B256 { - self.seal() - } -} - -/// Sealable objects. -pub trait Sealable: Sized { - /// Calculate the seal hash, this may be slow. - fn hash(&self) -> B256; - - /// Seal the object by calculating the hash. This may be slow. - fn seal_slow(self) -> Sealed { - let seal = self.hash(); - Sealed::new_unchecked(self, seal) - } - - /// Instantiate an unchecked seal. This should be used with caution. - fn seal_unchecked(self, seal: B256) -> Sealed { - Sealed::new_unchecked(self, seal) - } -}