aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorface <face@hmel.org>2016-04-17 10:58:50 +0300
committerNikolay Mitev <face@hmel.org>2016-04-19 20:33:04 +0300
commitd0a6353dec48f365c38de3c76b42f67eda737ed5 (patch)
tree6e62fa39e2a71cad2fa81c0c2ae530092af5bb6c /src
parent764d2377727c8945d648a018492a61add4fcf042 (diff)
downloadbitcoin-d0a6353dec48f365c38de3c76b42f67eda737ed5.tar.xz
Pass CChainParams to DisconnectTip()
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp11
-rw-r--r--src/main.h2
-rw-r--r--src/rpc/blockchain.cpp2
3 files changed, 7 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index aaf5f9ae64..5183930001 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -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. */
-bool static DisconnectTip(CValidationState& state, const Consensus::Params& consensusParams)
+bool static DisconnectTip(CValidationState& state, const CChainParams& chainparams)
{
- const CChainParams& chainparams = Params(); // TODO replace consensusParams parameter
CBlockIndex *pindexDelete = chainActive.Tip();
assert(pindexDelete);
// Read block from disk.
CBlock block;
- if (!ReadBlockFromDisk(block, pindexDelete, consensusParams))
+ if (!ReadBlockFromDisk(block, pindexDelete, chainparams.GetConsensus()))
return AbortNode(state, "Failed to read block");
// Apply the block atomically to the chain state.
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.
bool fBlocksDisconnected = false;
while (chainActive.Tip() && chainActive.Tip() != pindexFork) {
- if (!DisconnectTip(state, chainparams.GetConsensus()))
+ if (!DisconnectTip(state, chainparams))
return false;
fBlocksDisconnected = true;
}
@@ -2973,7 +2972,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
return true;
}
-bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensusParams, CBlockIndex *pindex)
+bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindex)
{
AssertLockHeld(cs_main);
@@ -2989,7 +2988,7 @@ bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensus
setBlockIndexCandidates.erase(pindexWalk);
// ActivateBestChain considers blocks already in chainActive
// unconditionally valid already, so force disconnect away from it.
- if (!DisconnectTip(state, consensusParams)) {
+ if (!DisconnectTip(state, chainparams)) {
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
return false;
}
diff --git a/src/main.h b/src/main.h
index 0962f44e94..e4c98a9696 100644
--- a/src/main.h
+++ b/src/main.h
@@ -536,7 +536,7 @@ public:
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator);
/** Mark a block as invalid. */
-bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensusParams, CBlockIndex *pindex);
+bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, CBlockIndex *pindex);
/** Remove invalidity status from a block and its descendants. */
bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex);
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index b85b2f6b57..2670a85c4f 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -928,7 +928,7 @@ UniValue invalidateblock(const UniValue& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlockIndex* pblockindex = mapBlockIndex[hash];
- InvalidateBlock(state, Params().GetConsensus(), pblockindex);
+ InvalidateBlock(state, Params(), pblockindex);
}
if (state.IsValid()) {