Skip to content

Commit

Permalink
consensus: add BlockWithParent (#1650)
Browse files Browse the repository at this point in the history
* consensus: add BlockWithParent

* mv BlockWithParent
  • Loading branch information
tcoratger authored Nov 16, 2024
1 parent 49245f2 commit 39ae9af
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions crates/eips/src/eip1898.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ use core::{
#[cfg(feature = "serde")]
use serde::ser::SerializeStruct;

/// A helper struct to store the block number/hash and its parent hash.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct BlockWithParent {
/// Parent hash.
pub parent: B256,
/// Block number/hash.
pub block: BlockNumHash,
}

impl BlockWithParent {
/// Creates a new [`BlockWithParent`] instance.
pub const fn new(parent: B256, block: BlockNumHash) -> Self {
Self { parent, block }
}
}

/// A block hash which may have a boolean `requireCanonical` field.
///
/// - If false, a RPC call should raise if a block matching the hash is not found.
Expand Down

0 comments on commit 39ae9af

Please sign in to comment.