@ -2897,14 +2897,15 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
@@ -2897,14 +2897,15 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
*/
bool ActivateBestChain ( CValidationState & state , const CChainParams & chainparams , const CBlock * pblock ) {
CBlockIndex * pindexMostWork = NULL ;
CBlockIndex * pindexNewTip = NULL ;
do {
boost : : this_thread : : interruption_point ( ) ;
if ( ShutdownRequested ( ) )
break ;
CBlockIndex * pindexNewTip = NULL ;
const CBlockIndex * pindexFork ;
bool fInitialDownload ;
int nNewHeight ;
{
LOCK ( cs_main ) ;
CBlockIndex * pindexOldTip = chainActive . Tip ( ) ;
@ -2920,6 +2921,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
@@ -2920,6 +2921,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
pindexNewTip = chainActive . Tip ( ) ;
pindexFork = chainActive . FindFork ( pindexOldTip ) ;
fInitialDownload = IsInitialBlockDownload ( ) ;
nNewHeight = chainActive . Height ( ) ;
}
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
@ -2948,7 +2950,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
@@ -2948,7 +2950,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
{
LOCK ( cs_vNodes ) ;
BOOST_FOREACH ( CNode * pnode , vNodes ) {
if ( chainActive . Height ( ) > ( pnode - > nStartingHeight ! = - 1 ? pnode - > nStartingHeight - 2000 : nBlockEstimate ) ) {
if ( nNewHeight > ( pnode - > nStartingHeight ! = - 1 ? pnode - > nStartingHeight - 2000 : nBlockEstimate ) ) {
BOOST_REVERSE_FOREACH ( const uint256 & hash , vHashes ) {
pnode - > PushBlockHash ( hash ) ;
}
@ -2961,7 +2963,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
@@ -2961,7 +2963,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
}
}
}
} while ( pindexMostWork ! = chainActive . Tip ( ) ) ;
} while ( pindexNewTip ! = pindexMostWork ) ;
CheckBlockIndex ( chainparams . GetConsensus ( ) ) ;
// Write changes periodically to disk, after relay.