Consistently use chainparams and consensusParams
This commit is contained in:
parent
a3b64d8677
commit
9e0f75dcbd
20
src/main.cpp
20
src/main.cpp
|
@ -4531,7 +4531,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RewindBlockIndex(const CChainParams& params, bool& clearWitnessCaches)
|
bool RewindBlockIndex(const CChainParams& chainparams, bool& clearWitnessCaches)
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
|
@ -4544,8 +4544,8 @@ bool RewindBlockIndex(const CChainParams& params, bool& clearWitnessCaches)
|
||||||
//
|
//
|
||||||
// - BLOCK_ACTIVATES_UPGRADE is set only on blocks that activate upgrades.
|
// - BLOCK_ACTIVATES_UPGRADE is set only on blocks that activate upgrades.
|
||||||
// - nCachedBranchId for each block matches what we expect.
|
// - nCachedBranchId for each block matches what we expect.
|
||||||
auto sufficientlyValidated = [¶ms](const CBlockIndex* pindex) {
|
auto sufficientlyValidated = [&chainparams](const CBlockIndex* pindex) {
|
||||||
auto consensus = params.GetConsensus();
|
auto consensus = chainparams.GetConsensus();
|
||||||
bool fFlagSet = pindex->nStatus & BLOCK_ACTIVATES_UPGRADE;
|
bool fFlagSet = pindex->nStatus & BLOCK_ACTIVATES_UPGRADE;
|
||||||
bool fFlagExpected = IsActivationHeightForAnyUpgrade(pindex->nHeight, consensus);
|
bool fFlagExpected = IsActivationHeightForAnyUpgrade(pindex->nHeight, consensus);
|
||||||
return fFlagSet == fFlagExpected &&
|
return fFlagSet == fFlagExpected &&
|
||||||
|
@ -4568,7 +4568,7 @@ bool RewindBlockIndex(const CChainParams& params, bool& clearWitnessCaches)
|
||||||
if (rewindLength > 0) {
|
if (rewindLength > 0) {
|
||||||
LogPrintf("*** First insufficiently validated block at height %d, rewind length %d\n", nHeight, rewindLength);
|
LogPrintf("*** First insufficiently validated block at height %d, rewind length %d\n", nHeight, rewindLength);
|
||||||
const uint256 *phashFirstInsufValidated = chainActive[nHeight]->phashBlock;
|
const uint256 *phashFirstInsufValidated = chainActive[nHeight]->phashBlock;
|
||||||
auto networkID = params.NetworkIDString();
|
auto networkID = chainparams.NetworkIDString();
|
||||||
|
|
||||||
// This is true when we intend to do a long rewind.
|
// This is true when we intend to do a long rewind.
|
||||||
bool intendedRewind =
|
bool intendedRewind =
|
||||||
|
@ -4615,7 +4615,7 @@ bool RewindBlockIndex(const CChainParams& params, bool& clearWitnessCaches)
|
||||||
// of the blockchain).
|
// of the blockchain).
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!DisconnectTip(state, params, true)) {
|
if (!DisconnectTip(state, chainparams, true)) {
|
||||||
return error("RewindBlockIndex: unable to disconnect block at height %i", pindex->nHeight);
|
return error("RewindBlockIndex: unable to disconnect block at height %i", pindex->nHeight);
|
||||||
}
|
}
|
||||||
// Occasionally flush state to disk.
|
// Occasionally flush state to disk.
|
||||||
|
@ -4677,7 +4677,7 @@ bool RewindBlockIndex(const CChainParams& params, bool& clearWitnessCaches)
|
||||||
|
|
||||||
PruneBlockIndexCandidates();
|
PruneBlockIndexCandidates();
|
||||||
|
|
||||||
CheckBlockIndex(params.GetConsensus());
|
CheckBlockIndex(chainparams.GetConsensus());
|
||||||
|
|
||||||
if (!FlushStateToDisk(state, FLUSH_STATE_ALWAYS)) {
|
if (!FlushStateToDisk(state, FLUSH_STATE_ALWAYS)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -5348,14 +5348,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reject incoming connections from nodes that don't know about the current epoch
|
// Reject incoming connections from nodes that don't know about the current epoch
|
||||||
const Consensus::Params& params = chainparams.GetConsensus();
|
const Consensus::Params& consensusParams = chainparams.GetConsensus();
|
||||||
auto currentEpoch = CurrentEpoch(GetHeight(), params);
|
auto currentEpoch = CurrentEpoch(GetHeight(), consensusParams);
|
||||||
if (pfrom->nVersion < params.vUpgrades[currentEpoch].nProtocolVersion)
|
if (pfrom->nVersion < consensusParams.vUpgrades[currentEpoch].nProtocolVersion)
|
||||||
{
|
{
|
||||||
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
|
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
|
||||||
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
||||||
strprintf("Version must be %d or greater",
|
strprintf("Version must be %d or greater",
|
||||||
params.vUpgrades[currentEpoch].nProtocolVersion));
|
consensusParams.vUpgrades[currentEpoch].nProtocolVersion));
|
||||||
pfrom->fDisconnect = true;
|
pfrom->fDisconnect = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,7 +480,7 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams,
|
||||||
* clearWitnessCaches is an output parameter that will be set to true iff
|
* clearWitnessCaches is an output parameter that will be set to true iff
|
||||||
* witness caches should be cleared in order to handle an intended long rewind.
|
* witness caches should be cleared in order to handle an intended long rewind.
|
||||||
*/
|
*/
|
||||||
bool RewindBlockIndex(const CChainParams& params, bool& clearWitnessCaches);
|
bool RewindBlockIndex(const CChainParams& chainparams, bool& clearWitnessCaches);
|
||||||
|
|
||||||
/** RAII wrapper for VerifyDB: Verify consistency of the block and coin databases */
|
/** RAII wrapper for VerifyDB: Verify consistency of the block and coin databases */
|
||||||
class CVerifyDB {
|
class CVerifyDB {
|
||||||
|
|
Loading…
Reference in New Issue