From ed470940cddbeb40425960d51cefeec4948febe4 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 7 Aug 2022 20:56:17 -0400 Subject: Add functions to construct locators without CChain This introduces an insignificant performance penalty, as it means locator construction needs to use the skiplist-based CBlockIndex::GetAncestor() function instead of the lookup-based CChain, but avoids the need for callers to have access to a relevant CChain object. --- src/chain.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/chain.h') diff --git a/src/chain.h b/src/chain.h index cc1d9e2d22..2d3b084b9b 100644 --- a/src/chain.h +++ b/src/chain.h @@ -473,8 +473,8 @@ public: /** Set/initialize a chain with a given tip. */ void SetTip(CBlockIndex& block); - /** Return a CBlockLocator that refers to a block in this chain (by default the tip). */ - CBlockLocator GetLocator(const CBlockIndex* pindex = nullptr) const; + /** Return a CBlockLocator that refers to the tip in of this chain. */ + CBlockLocator GetLocator() const; /** Find the last common block between this chain and a block index entry. */ const CBlockIndex* FindFork(const CBlockIndex* pindex) const; @@ -483,4 +483,10 @@ public: CBlockIndex* FindEarliestAtLeast(int64_t nTime, int height) const; }; +/** Get a locator for a block index entry. */ +CBlockLocator GetLocator(const CBlockIndex* index); + +/** Construct a list of hash entries to put in a locator. */ +std::vector LocatorEntries(const CBlockIndex* index); + #endif // BITCOIN_CHAIN_H -- cgit v1.2.3