Skip to content

Commit

Permalink
Reenable the option to disable checkpoints (#1309)
Browse files Browse the repository at this point in the history
* Restore disabling of checkpoints for testing

* Log config

* Update init.cpp

* Update init.cpp

Co-authored-by: Mihailo Milenkovic <[email protected]>
  • Loading branch information
prasannavl and Mixa84 authored May 31, 2022
1 parent 4390fc5 commit f3ad826
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,3 +1060,7 @@ void SelectParams(const std::string& network)
SelectBaseParams(network);
globalChainParams = CreateChainParams(network);
}

void ClearCheckpoints(CChainParams &params) {
params.checkpointData = {};
}
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class CChainParams
std::vector<MasternodeKeys> vMasternodes;
std::vector<CTransactionRef> CreateGenesisMasternodes();
std::set<CKeyID> genesisTeam;

friend void ClearCheckpoints(CChainParams &params);
};

const auto SMART_CONTRACT_DFIP_2201 = "DFIP2201";
Expand Down
12 changes: 9 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,14 @@ bool AppInitParameterInteraction()
mempool.setSanityCheck(1.0 / ratio);
}
fCheckBlockIndex = gArgs.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
if (gArgs.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED))
LogPrintf("Warning: -checkpoints does nothing, it will be removed in next release.\n");
if (!gArgs.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED)) {
LogPrintf("conf: checkpoints disabled.\n");
// Safe to const_cast, as we know it's always allocated, and is always in the global var
// and it is not used anywhere yet.
ClearCheckpoints(const_cast<CChainParams&>(chainparams));
} else {
LogPrintf("conf: checkpoints enabled.\n");
}

hashAssumeValid = uint256S(gArgs.GetArg("-assumevalid", chainparams.GetConsensus().defaultAssumeValid.GetHex()));
if (!hashAssumeValid.IsNull())
Expand Down Expand Up @@ -1360,7 +1366,7 @@ bool AppInitMain(InitInterfaces& interfaces)
// Warn about relative -datadir path.
if (gArgs.IsArgSet("-datadir") && !fs::path(gArgs.GetArg("-datadir", "")).is_absolute()) {
LogPrintf("Warning: relative datadir option '%s' specified, which will be interpreted relative to the " /* Continued */
"current working directory '%s'. This is fragile, because if defi is started in the future "
"current working directory '%s'. This is fragile, because if defid is started in the future "
"from a different location, it will be unable to locate the current data files. There could "
"also be data loss if defi is started while in a temporary directory.\n",
gArgs.GetArg("-datadir", ""), fs::current_path().string());
Expand Down
3 changes: 1 addition & 2 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static const int64_t DEFAULT_MAX_TIP_AGE = 10 * 60 * 60;
/** Maximum age of our tip in seconds for us to be considered current for fee estimation */
static const int64_t MAX_FEE_ESTIMATION_TIP_AGE = 10 * 60;

static const bool DEFAULT_CHECKPOINTS_ENABLED = false;
static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
static const bool DEFAULT_TXINDEX = false;
static const char* const DEFAULT_BLOCKFILTERINDEX = "0";
static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
Expand Down Expand Up @@ -160,7 +160,6 @@ extern std::atomic_bool fReindex;
extern int nScriptCheckThreads;
extern bool fRequireStandard;
extern bool fCheckBlockIndex;
extern bool fCheckpointsEnabled;

extern bool fStopOrInterrupt;
extern std::string fInterruptBlockHash;
Expand Down

0 comments on commit f3ad826

Please sign in to comment.