mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make block field private (#13628)
This commit is contained in:
@ -16,14 +16,14 @@ impl TryFrom<AnyRpcBlock> for SealedBlock {
|
||||
let block_hash = block.header.hash;
|
||||
let block = block.try_map_transactions(|tx| tx.try_into())?;
|
||||
|
||||
Ok(Self {
|
||||
header: SealedHeader::new(block.header.inner.into_header_with_defaults(), block_hash),
|
||||
body: BlockBody {
|
||||
Ok(Self::new(
|
||||
SealedHeader::new(block.header.inner.into_header_with_defaults(), block_hash),
|
||||
BlockBody {
|
||||
transactions: block.transactions.into_transactions().collect(),
|
||||
ommers: Default::default(),
|
||||
withdrawals: block.withdrawals.map(|w| w.into_inner().into()),
|
||||
},
|
||||
})
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -169,7 +169,7 @@ pub struct SealedBlock<H = Header, B = BlockBody> {
|
||||
#[deref_mut]
|
||||
pub header: SealedHeader<H>,
|
||||
/// Block body.
|
||||
pub body: B,
|
||||
body: B,
|
||||
}
|
||||
|
||||
impl<H, B> SealedBlock<H, B> {
|
||||
@ -190,6 +190,16 @@ impl<H, B> SealedBlock<H, B> {
|
||||
&self.body
|
||||
}
|
||||
|
||||
/// Consumes the block and returns the header.
|
||||
pub fn into_header(self) -> H {
|
||||
self.header.unseal()
|
||||
}
|
||||
|
||||
/// Consumes the block and returns the body.
|
||||
pub fn into_body(self) -> B {
|
||||
self.body
|
||||
}
|
||||
|
||||
/// Splits the [`BlockBody`] and [`SealedHeader`] into separate components
|
||||
#[inline]
|
||||
pub fn split_header_body(self) -> (SealedHeader<H>, B) {
|
||||
|
||||
@ -13,7 +13,7 @@ pub trait BlockExt: Block {
|
||||
/// Calculate the header hash and seal the block so that it can't be changed.
|
||||
fn seal_slow(self) -> SealedBlock<Self::Header, Self::Body> {
|
||||
let (header, body) = self.split();
|
||||
SealedBlock { header: SealedHeader::seal(header), body }
|
||||
SealedBlock::new(SealedHeader::seal(header), body)
|
||||
}
|
||||
|
||||
/// Seal the block with a known hash.
|
||||
@ -21,7 +21,7 @@ pub trait BlockExt: Block {
|
||||
/// WARNING: This method does not perform validation whether the hash is correct.
|
||||
fn seal(self, hash: B256) -> SealedBlock<Self::Header, Self::Body> {
|
||||
let (header, body) = self.split();
|
||||
SealedBlock { header: SealedHeader::new(header, hash), body }
|
||||
SealedBlock::new(SealedHeader::new(header, hash), body)
|
||||
}
|
||||
|
||||
/// Expensive operation that recovers transaction signer.
|
||||
|
||||
Reference in New Issue
Block a user