From d4bdff08f7de754461d9364302b7e8371e3d234e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BF=97=E5=AE=87?= Date: Fri, 9 Jan 2026 17:09:03 +0800 Subject: [PATCH] feat(core): Add `prev_blockhash` method to `ToBlockHash` trait --- crates/core/src/checkpoint.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/core/src/checkpoint.rs b/crates/core/src/checkpoint.rs index 0a394122..edb420dc 100644 --- a/crates/core/src/checkpoint.rs +++ b/crates/core/src/checkpoint.rs @@ -65,6 +65,11 @@ impl Drop for CPInner { pub trait ToBlockHash { /// Returns the [`BlockHash`] for the associated [`CheckPoint`] `data` type. fn to_blockhash(&self) -> BlockHash; + + /// Returns `None` if the type has no knowledge of the previous [`BlockHash`]. + fn prev_blockhash(&self) -> Option { + None + } } impl ToBlockHash for BlockHash { @@ -77,6 +82,10 @@ impl ToBlockHash for Header { fn to_blockhash(&self) -> BlockHash { self.block_hash() } + + fn prev_blockhash(&self) -> Option { + Some(self.prev_blockhash) + } } /// Trait that extracts a block time from [`CheckPoint`] `data`. -- 2.49.0