feat: find canonical ancestor (#2506)

This commit is contained in:
Matthias Seitz
2023-05-02 13:07:00 +02:00
committed by GitHub
parent 174316936b
commit c62c7d6f1d
5 changed files with 62 additions and 7 deletions

View File

@ -94,6 +94,12 @@ pub trait BlockchainTreeViewer: Send + Sync {
/// Canonical block number and hashes best known by the tree.
fn canonical_blocks(&self) -> BTreeMap<BlockNumber, BlockHash>;
/// Given a hash, this tries to find the last ancestor that is part of the canonical chain.
///
/// In other words, this will walk up the chain starting with the given hash and return the
/// first block that's canonical.
fn find_canonical_ancestor(&self, hash: BlockHash) -> Option<BlockHash>;
/// Return BlockchainTree best known canonical chain tip (BlockHash, BlockNumber)
fn canonical_tip(&self) -> BlockNumHash;