@@ -2628,14 +2628,13 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
26282628}
26292629
26302630/* * Disconnect chainActive's tip. You probably want to call mempool.removeForReorg and manually re-limit mempool size after this, with cs_main held. */
2631- bool static DisconnectTip (CValidationState& state, const Consensus::Params& consensusParams )
2631+ bool static DisconnectTip (CValidationState& state, const CChainParams& chainparams )
26322632{
2633- const CChainParams& chainparams = Params (); // TODO replace consensusParams parameter
26342633 CBlockIndex *pindexDelete = chainActive.Tip ();
26352634 assert (pindexDelete);
26362635 // Read block from disk.
26372636 CBlock block;
2638- if (!ReadBlockFromDisk (block, pindexDelete, consensusParams ))
2637+ if (!ReadBlockFromDisk (block, pindexDelete, chainparams. GetConsensus () ))
26392638 return AbortNode (state, " Failed to read block" );
26402639 // Apply the block atomically to the chain state.
26412640 int64_t nStart = GetTimeMicros ();
@@ -2828,7 +2827,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
28282827 // Disconnect active blocks which are no longer in the best chain.
28292828 bool fBlocksDisconnected = false ;
28302829 while (chainActive.Tip () && chainActive.Tip () != pindexFork) {
2831- if (!DisconnectTip (state, chainparams. GetConsensus () ))
2830+ if (!DisconnectTip (state, chainparams))
28322831 return false ;
28332832 fBlocksDisconnected = true ;
28342833 }
@@ -2973,7 +2972,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
29732972 return true ;
29742973}
29752974
2976- bool InvalidateBlock (CValidationState& state, const Consensus::Params& consensusParams , CBlockIndex *pindex)
2975+ bool InvalidateBlock (CValidationState& state, const CChainParams& chainparams , CBlockIndex *pindex)
29772976{
29782977 AssertLockHeld (cs_main);
29792978
@@ -2989,7 +2988,7 @@ bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensus
29892988 setBlockIndexCandidates.erase (pindexWalk);
29902989 // ActivateBestChain considers blocks already in chainActive
29912990 // unconditionally valid already, so force disconnect away from it.
2992- if (!DisconnectTip (state, consensusParams )) {
2991+ if (!DisconnectTip (state, chainparams )) {
29932992 mempool.removeForReorg (pcoinsTip, chainActive.Tip ()->nHeight + 1 , STANDARD_LOCKTIME_VERIFY_FLAGS);
29942993 return false ;
29952994 }
0 commit comments