Skip to content

Commit d0a6353

Browse files
committed
Pass CChainParams to DisconnectTip()
1 parent 764d237 commit d0a6353

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/main.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ class CVerifyDB {
536536
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator);
537537

538538
/** Mark a block as invalid. */
539-
bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensusParams, CBlockIndex *pindex);
539+
bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindex);
540540

541541
/** Remove invalidity status from a block and its descendants. */
542542
bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex);

src/rpc/blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ UniValue invalidateblock(const UniValue& params, bool fHelp)
928928
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
929929

930930
CBlockIndex* pblockindex = mapBlockIndex[hash];
931-
InvalidateBlock(state, Params().GetConsensus(), pblockindex);
931+
InvalidateBlock(state, Params(), pblockindex);
932932
}
933933

934934
if (state.IsValid()) {

0 commit comments

Comments
 (0)