Skip to content

Commit

Permalink
consensus: implement seal helper for Header (#1269)
Browse files Browse the repository at this point in the history
* consensus: implement seal helper for Header

* fix clippy
  • Loading branch information
tcoratger authored Sep 10, 2024
1 parent 30897cc commit 043dc20
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/consensus/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use alloy_eips::{
BlockNumHash,
};
use alloy_primitives::{
b256, keccak256, Address, BlockNumber, Bloom, Bytes, Sealable, B256, B64, U256,
b256, keccak256, Address, BlockNumber, Bloom, Bytes, Sealable, Sealed, B256, B64, U256,
};
use alloy_rlp::{
length_of_length, Buf, BufMut, Decodable, Encodable, EMPTY_LIST_CODE, EMPTY_STRING_CODE,
Expand Down Expand Up @@ -370,6 +370,14 @@ impl Header {
pub const fn exceeds_allowed_future_timestamp(&self, present_timestamp: u64) -> bool {
self.timestamp > present_timestamp + ALLOWED_FUTURE_BLOCK_TIME_SECONDS
}

/// Seal the header with a known hash.
///
/// WARNING: This method does not perform validation whether the hash is correct.
#[inline]
pub const fn seal(self, hash: B256) -> Sealed<Self> {
Sealed::new_unchecked(self, hash)
}
}

impl Encodable for Header {
Expand Down

0 comments on commit 043dc20

Please sign in to comment.