Skip to content

Commit

Permalink
consensus: implement seal helper for Header
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger committed Sep 10, 2024
1 parent 75d4d0c commit c678cae
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 @@ -5,7 +5,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 @@ -379,6 +379,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<Header> {
Sealed::new_unchecked(self, hash)
}
}

impl Encodable for Header {
Expand Down

0 comments on commit c678cae

Please sign in to comment.