| 24 | } |
| 25 | |
| 26 | std::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 | |
| 45 | CBlockLocator GetLocator(const CBlockIndex* index) |
| 46 | { |
no test coverage detected