From: 志宇 Date: Fri, 9 Jan 2026 09:09:03 +0000 (+0800) Subject: feat(core): Add `prev_blockhash` method to `ToBlockHash` trait X-Git-Url: http://internal-gitweb-vhost/?a=commitdiff_plain;h=d4bdff08f7de754461d9364302b7e8371e3d234e;p=bdk feat(core): Add `prev_blockhash` method to `ToBlockHash` trait --- 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`.