Skip to content

Commit 55e4ce5

Browse files
committed
feat(core): Add prev_blockhash method to ToBlockHash trait
1 parent be356d5 commit 55e4ce5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/core/src/checkpoint.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ impl<D> Drop for CPInner<D> {
6464
pub trait ToBlockHash {
6565
/// Returns the [`BlockHash`] for the associated [`CheckPoint`] `data` type.
6666
fn to_blockhash(&self) -> BlockHash;
67+
68+
/// Returns `None` if the type has no knowledge of the previous [`BlockHash`].
69+
fn prev_blockhash(&self) -> Option<BlockHash> {
70+
None
71+
}
6772
}
6873

6974
impl ToBlockHash for BlockHash {
@@ -76,6 +81,10 @@ impl ToBlockHash for Header {
7681
fn to_blockhash(&self) -> BlockHash {
7782
self.block_hash()
7883
}
84+
85+
fn prev_blockhash(&self) -> Option<BlockHash> {
86+
Some(self.prev_blockhash)
87+
}
7988
}
8089

8190
impl<D> PartialEq for CheckPoint<D> {

0 commit comments

Comments
 (0)