@@ -2897,14 +2897,15 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
2897
2897
*/
2898
2898
bool ActivateBestChain (CValidationState &state, const CChainParams& chainparams, const CBlock *pblock) {
2899
2899
CBlockIndex *pindexMostWork = NULL ;
2900
+ CBlockIndex *pindexNewTip = NULL ;
2900
2901
do {
2901
2902
boost::this_thread::interruption_point ();
2902
2903
if (ShutdownRequested ())
2903
2904
break ;
2904
2905
2905
- CBlockIndex *pindexNewTip = NULL ;
2906
2906
const CBlockIndex *pindexFork;
2907
2907
bool fInitialDownload ;
2908
+ int nNewHeight;
2908
2909
{
2909
2910
LOCK (cs_main);
2910
2911
CBlockIndex *pindexOldTip = chainActive.Tip ();
@@ -2920,6 +2921,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
2920
2921
pindexNewTip = chainActive.Tip ();
2921
2922
pindexFork = chainActive.FindFork (pindexOldTip);
2922
2923
fInitialDownload = IsInitialBlockDownload ();
2924
+ nNewHeight = chainActive.Height ();
2923
2925
}
2924
2926
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
2925
2927
@@ -2948,7 +2950,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
2948
2950
{
2949
2951
LOCK (cs_vNodes);
2950
2952
BOOST_FOREACH (CNode* pnode, vNodes) {
2951
- if (chainActive. Height () > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) {
2953
+ if (nNewHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) {
2952
2954
BOOST_REVERSE_FOREACH (const uint256& hash, vHashes) {
2953
2955
pnode->PushBlockHash (hash);
2954
2956
}
@@ -2961,7 +2963,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
2961
2963
}
2962
2964
}
2963
2965
}
2964
- } while (pindexMostWork != chainActive. Tip () );
2966
+ } while (pindexNewTip != pindexMostWork );
2965
2967
CheckBlockIndex (chainparams.GetConsensus ());
2966
2968
2967
2969
// Write changes periodically to disk, after relay.
0 commit comments