From e60c2f66a3e04e4437cfdd38ef56848abf2938b3 Mon Sep 17 00:00:00 2001 From: Thomas Coratger Date: Wed, 4 Sep 2024 16:36:50 +0200 Subject: [PATCH] consensus: impl parent_num_hash for Header --- crates/consensus/src/header.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/consensus/src/header.rs b/crates/consensus/src/header.rs index f593b873929..f493263b0ce 100644 --- a/crates/consensus/src/header.rs +++ b/crates/consensus/src/header.rs @@ -1,6 +1,7 @@ use alloy_eips::{ eip1559::{calc_next_block_base_fee, BaseFeeParams}, eip4844::{calc_blob_gasprice, calc_excess_blob_gas}, + BlockNumHash, }; use alloy_primitives::{ b256, keccak256, Address, BlockNumber, Bloom, Bytes, Sealable, B256, B64, U256, @@ -344,6 +345,11 @@ impl Header { length } + + /// Returns the parent block's number and hash + pub const fn parent_num_hash(&self) -> BlockNumHash { + BlockNumHash { number: self.number.saturating_sub(1), hash: self.parent_hash } + } } impl Encodable for Header {