From ac385d0f9f94adf7d151130f942b023a93f49c59 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 9 Jan 2025 15:03:21 +0100 Subject: [PATCH] feat: add helper to forkchoice state --- crates/rpc-types-engine/src/forkchoice.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/rpc-types-engine/src/forkchoice.rs b/crates/rpc-types-engine/src/forkchoice.rs index 6c13d2856ba..5d4b6bfabe1 100644 --- a/crates/rpc-types-engine/src/forkchoice.rs +++ b/crates/rpc-types-engine/src/forkchoice.rs @@ -31,6 +31,12 @@ pub struct ForkchoiceState { } impl ForkchoiceState { + /// Creates a new [ForkchoiceState] with head, safe, and finalized block hashes set to the given + /// hash. + pub const fn same_hash(hash: B256) -> Self { + Self { head_block_hash: hash, safe_block_hash: hash, finalized_block_hash: hash } + } + /// Returns the `head_block_hash`, only if it is not [`B256::ZERO`], otherwise this returns /// [`None`]. #[inline]