Skip to content

Commit

Permalink
chore: misc sealed fn (#13378)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 13, 2024
1 parent f347977 commit 088925c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/chain-state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ impl<N: NodePrimitives> BlockState<N> {
pub fn block_with_senders(&self) -> BlockWithSenders<N::Block> {
let block = self.block.block().clone();
let senders = self.block.senders().clone();
let (header, body) = block.split();
let (header, body) = block.split_header_body();
BlockWithSenders::new_unchecked(N::Block::new(header.unseal(), body), senders)
}

Expand Down
8 changes: 8 additions & 0 deletions crates/primitives-traits/src/header/sealed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ impl<H> SealedHeader<H> {
&self.header
}

/// Clone the header.
pub fn clone_header(&self) -> H
where
H: Clone,
{
self.header.clone()
}

/// Returns header/block hash.
#[inline]
pub const fn hash(&self) -> BlockHash {
Expand Down
13 changes: 6 additions & 7 deletions crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ impl<H, B> SealedBlock<H, B> {
self.header.hash()
}

/// Returns reference to block body.
pub const fn body(&self) -> &B {
&self.body
}

/// Splits the [`BlockBody`] and [`SealedHeader`] into separate components
#[inline]
pub fn split_header_body(self) -> (SealedHeader<H>, B) {
Expand Down Expand Up @@ -326,12 +331,6 @@ where
H: reth_primitives_traits::BlockHeader,
B: reth_primitives_traits::BlockBody,
{
/// Splits the sealed block into underlying components
#[inline]
pub fn split(self) -> (SealedHeader<H>, B) {
(self.header, self.body)
}

/// Expensive operation that recovers transaction signer. See [`SealedBlockWithSenders`].
pub fn senders(&self) -> Option<Vec<Address>>
where
Expand Down Expand Up @@ -496,7 +495,7 @@ impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
#[inline]
pub fn unseal(self) -> BlockWithSenders<B> {
let (block, senders) = self.into_components();
let (header, body) = block.split();
let (header, body) = block.split_header_body();
let header = header.unseal();
BlockWithSenders::new_unchecked(B::new(header, body), senders)
}
Expand Down

0 comments on commit 088925c

Please sign in to comment.