File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -423,15 +423,13 @@ CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
423
423
break ;
424
424
// Exponentially larger steps back, plus the genesis block.
425
425
int nHeight = std::max (pindex->nHeight - nStep, 0 );
426
- // Jump back quickly to the same height as the chain.
427
- if (pindex->nHeight > nHeight)
428
- pindex = pindex->GetAncestor (nHeight);
429
- // In case pindex is not in this chain, iterate pindex->pprev to find blocks.
430
- while (!Contains (pindex))
431
- pindex = pindex->pprev ;
432
- // If pindex is in this chain, use direct height-based access.
433
- if (pindex->nHeight > nHeight)
426
+ if (Contains (pindex)) {
427
+ // Use O(1) CChain index if possible.
434
428
pindex = (*this )[nHeight];
429
+ } else {
430
+ // Otherwise, use O(log n) skiplist.
431
+ pindex = pindex->GetAncestor (nHeight);
432
+ }
435
433
if (vHave.size () > 10 )
436
434
nStep *= 2 ;
437
435
}
You can’t perform that action at this time.
0 commit comments