From 44466d7f82a9969f27633d326176fa813126e548 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 13 Dec 2024 12:26:30 +0100 Subject: [PATCH] chore: misc sealed fn --- crates/chain-state/src/in_memory.rs | 2 +- crates/primitives-traits/src/header/sealed.rs | 8 ++++++++ crates/primitives/src/block.rs | 13 ++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/crates/chain-state/src/in_memory.rs b/crates/chain-state/src/in_memory.rs index 5b8bb150804e..3f8fa8a5a88e 100644 --- a/crates/chain-state/src/in_memory.rs +++ b/crates/chain-state/src/in_memory.rs @@ -640,7 +640,7 @@ impl BlockState { pub fn block_with_senders(&self) -> BlockWithSenders { 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) } diff --git a/crates/primitives-traits/src/header/sealed.rs b/crates/primitives-traits/src/header/sealed.rs index 61b021a0879b..ef8b5fde5e91 100644 --- a/crates/primitives-traits/src/header/sealed.rs +++ b/crates/primitives-traits/src/header/sealed.rs @@ -35,6 +35,14 @@ impl SealedHeader { &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 { diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 777bb06e6f32..e99c77f8ca3f 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -255,6 +255,11 @@ impl SealedBlock { 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, B) { @@ -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, B) { - (self.header, self.body) - } - /// Expensive operation that recovers transaction signer. See [`SealedBlockWithSenders`]. pub fn senders(&self) -> Option> where @@ -496,7 +495,7 @@ impl SealedBlockWithSenders { #[inline] pub fn unseal(self) -> BlockWithSenders { 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) }