Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: misc sealed fn #13378

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading