@@ -2525,43 +2525,43 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
2525
2525
bool fContinue = true ;
2526
2526
int nHeight = pindexFork ? pindexFork->nHeight : -1 ;
2527
2527
while (fContinue && nHeight != pindexMostWork->nHeight ) {
2528
- // Don't iterate the entire list of potential improvements toward the best tip, as we likely only need
2529
- // a few blocks along the way.
2530
- int nTargetHeight = std::min (nHeight + 32 , pindexMostWork->nHeight );
2531
- vpindexToConnect.clear ();
2532
- vpindexToConnect.reserve (nTargetHeight - nHeight);
2533
- CBlockIndex *pindexIter = pindexMostWork->GetAncestor (nTargetHeight);
2534
- while (pindexIter && pindexIter->nHeight != nHeight) {
2535
- vpindexToConnect.push_back (pindexIter);
2536
- pindexIter = pindexIter->pprev ;
2537
- }
2538
- nHeight = nTargetHeight;
2539
-
2540
- // Connect new blocks.
2541
- BOOST_REVERSE_FOREACH (CBlockIndex *pindexConnect, vpindexToConnect) {
2542
- if (!ConnectTip (state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL )) {
2543
- if (state.IsInvalid ()) {
2544
- // The block violates a consensus rule.
2545
- if (!state.CorruptionPossible ())
2546
- InvalidChainFound (vpindexToConnect.back ());
2547
- state = CValidationState ();
2548
- fInvalidFound = true ;
2549
- fContinue = false ;
2550
- break ;
2528
+ // Don't iterate the entire list of potential improvements toward the best tip, as we likely only need
2529
+ // a few blocks along the way.
2530
+ int nTargetHeight = std::min (nHeight + 32 , pindexMostWork->nHeight );
2531
+ vpindexToConnect.clear ();
2532
+ vpindexToConnect.reserve (nTargetHeight - nHeight);
2533
+ CBlockIndex *pindexIter = pindexMostWork->GetAncestor (nTargetHeight);
2534
+ while (pindexIter && pindexIter->nHeight != nHeight) {
2535
+ vpindexToConnect.push_back (pindexIter);
2536
+ pindexIter = pindexIter->pprev ;
2537
+ }
2538
+ nHeight = nTargetHeight;
2539
+
2540
+ // Connect new blocks.
2541
+ BOOST_REVERSE_FOREACH (CBlockIndex *pindexConnect, vpindexToConnect) {
2542
+ if (!ConnectTip (state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL )) {
2543
+ if (state.IsInvalid ()) {
2544
+ // The block violates a consensus rule.
2545
+ if (!state.CorruptionPossible ())
2546
+ InvalidChainFound (vpindexToConnect.back ());
2547
+ state = CValidationState ();
2548
+ fInvalidFound = true ;
2549
+ fContinue = false ;
2550
+ break ;
2551
+ } else {
2552
+ // A system error occurred (disk space, database error, ...).
2553
+ return false ;
2554
+ }
2551
2555
} else {
2552
- // A system error occurred (disk space, database error, ...).
2553
- return false ;
2554
- }
2555
- } else {
2556
- PruneBlockIndexCandidates ();
2557
- if (!pindexOldTip || chainActive.Tip ()->nChainWork > pindexOldTip->nChainWork ) {
2558
- // We're in a better position than we were. Return temporarily to release the lock.
2559
- fContinue = false ;
2560
- break ;
2556
+ PruneBlockIndexCandidates ();
2557
+ if (!pindexOldTip || chainActive.Tip ()->nChainWork > pindexOldTip->nChainWork ) {
2558
+ // We're in a better position than we were. Return temporarily to release the lock.
2559
+ fContinue = false ;
2560
+ break ;
2561
+ }
2561
2562
}
2562
2563
}
2563
2564
}
2564
- }
2565
2565
2566
2566
if (fBlocksDisconnected )
2567
2567
mempool.TrimToSize (GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 );
0 commit comments