MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / LocatorEntries

Function LocatorEntries

src/chain.cpp:26–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26std::vector<uint256> LocatorEntries(const CBlockIndex* index)
27{
28 int step = 1;
29 std::vector<uint256> have;
30 if (index == nullptr) return have;
31
32 have.reserve(32);
33 while (index) {
34 have.emplace_back(index->GetBlockHash());
35 if (index->nHeight == 0) break;
36 // Exponentially larger steps back, plus the genesis block.
37 int height = std::max(index->nHeight - step, 0);
38 // Use skiplist.
39 index = index->GetAncestor(height);
40 if (have.size() > 10) step *= 2;
41 }
42 return have;
43}
44
45CBlockLocator GetLocator(const CBlockIndex* index)
46{

Callers 2

GetLocatorFunction · 0.85

Calls 5

reserveMethod · 0.45
emplace_backMethod · 0.45
GetBlockHashMethod · 0.45
GetAncestorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected