Skip to content

Commit

Permalink
feat: add missing helper fns (#1880)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jan 3, 2025
1 parent 7259b76 commit 6e49ed0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/consensus/src/block/header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::constants::{EMPTY_OMMER_ROOT_HASH, EMPTY_ROOT_HASH};
use crate::{
constants::{EMPTY_OMMER_ROOT_HASH, EMPTY_ROOT_HASH},
Block, BlockBody,
};
use alloc::vec::Vec;
use alloy_eips::{
eip1559::{calc_next_block_base_fee, BaseFeeParams},
Expand Down Expand Up @@ -168,6 +171,11 @@ impl Sealable for Header {
}

impl Header {
/// Create a [`Block`] from the body and its header.
pub const fn into_block<T>(self, body: BlockBody<T>) -> Block<T> {
body.into_block(self)
}

/// Heavy function that will calculate hash of data and will *not* save the change to metadata.
///
/// Use [`Header::seal_slow`] and unlock if you need the hash to be persistent.
Expand Down
5 changes: 5 additions & 0 deletions crates/consensus/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ pub struct Block<T, H = Header> {
}

impl<T, H> Block<T, H> {
/// Creates a new block with the given header and body.
pub const fn new(header: H, body: BlockBody<T>) -> Self {
Self { header, body }
}

/// Creates a new empty uncle block.
pub fn uncle(header: H) -> Self {
Self { header, body: Default::default() }
Expand Down

0 comments on commit 6e49ed0

Please sign in to comment.