aboutsummaryrefslogtreecommitdiff
path: root/src/chain.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2022-08-07 20:56:17 -0400
committerSuhas Daftuar <sdaftuar@gmail.com>2022-08-23 16:05:00 -0400
commited470940cddbeb40425960d51cefeec4948febe4 (patch)
tree91f598eec25c5714404c3c085a0e3d98be9cb73c /src/chain.h
parent84852bb6bb3579e475ce78fe729fd125ddbc715f (diff)
downloadbitcoin-ed470940cddbeb40425960d51cefeec4948febe4.tar.xz
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.
Diffstat (limited to 'src/chain.h')
-rw-r--r--src/chain.h10
1 files changed, 8 insertions, 2 deletions
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<uint256> LocatorEntries(const CBlockIndex* index);
+
#endif // BITCOIN_CHAIN_H