@ -2628,14 +2628,13 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
}
}
/** Disconnect chainActive's tip. You probably want to call mempool.removeForReorg and manually re-limit mempool size after this, with cs_main held. */
/** Disconnect chainActive's tip. You probably want to call mempool.removeForReorg and manually re-limit mempool size after this, with cs_main held. */
bool static DisconnectTip ( CValidationState & state , const C onsensus: : Params & consensusP arams)
bool static DisconnectTip ( CValidationState & state , const C ChainParams& chainp arams)
{
{
const CChainParams & chainparams = Params ( ) ; // TODO replace consensusParams parameter
CBlockIndex * pindexDelete = chainActive . Tip ( ) ;
CBlockIndex * pindexDelete = chainActive . Tip ( ) ;
assert ( pindexDelete ) ;
assert ( pindexDelete ) ;
// Read block from disk.
// Read block from disk.
CBlock block ;
CBlock block ;
if ( ! ReadBlockFromDisk ( block , pindexDelete , c onsensusParams ) )
if ( ! ReadBlockFromDisk ( block , pindexDelete , c hainparams. GetConsensus ( ) ) )
return AbortNode ( state , " Failed to read block " ) ;
return AbortNode ( state , " Failed to read block " ) ;
// Apply the block atomically to the chain state.
// Apply the block atomically to the chain state.
int64_t nStart = GetTimeMicros ( ) ;
int64_t nStart = GetTimeMicros ( ) ;
@ -2828,7 +2827,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
// Disconnect active blocks which are no longer in the best chain.
// Disconnect active blocks which are no longer in the best chain.
bool fBlocksDisconnected = false ;
bool fBlocksDisconnected = false ;
while ( chainActive . Tip ( ) & & chainActive . Tip ( ) ! = pindexFork ) {
while ( chainActive . Tip ( ) & & chainActive . Tip ( ) ! = pindexFork ) {
if ( ! DisconnectTip ( state , chainparams .GetConsensus ( ) ))
if ( ! DisconnectTip ( state , chainparams ))
return false ;
return false ;
fBlocksDisconnected = true ;
fBlocksDisconnected = true ;
}
}
@ -2973,7 +2972,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
return true ;
return true ;
}
}
bool InvalidateBlock ( CValidationState & state , const C onsensus: : Params & consensusP arams, CBlockIndex * pindex )
bool InvalidateBlock ( CValidationState & state , const C ChainParams& chainp arams, CBlockIndex * pindex )
{
{
AssertLockHeld ( cs_main ) ;
AssertLockHeld ( cs_main ) ;
@ -2989,7 +2988,7 @@ bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensus
setBlockIndexCandidates . erase ( pindexWalk ) ;
setBlockIndexCandidates . erase ( pindexWalk ) ;
// ActivateBestChain considers blocks already in chainActive
// ActivateBestChain considers blocks already in chainActive
// unconditionally valid already, so force disconnect away from it.
// unconditionally valid already, so force disconnect away from it.
if ( ! DisconnectTip ( state , c onsensusP arams) ) {
if ( ! DisconnectTip ( state , c hainp arams) ) {
mempool . removeForReorg ( pcoinsTip , chainActive . Tip ( ) - > nHeight + 1 , STANDARD_LOCKTIME_VERIFY_FLAGS ) ;
mempool . removeForReorg ( pcoinsTip , chainActive . Tip ( ) - > nHeight + 1 , STANDARD_LOCKTIME_VERIFY_FLAGS ) ;
return false ;
return false ;
}
}