Skip to content

Commit fa43188

Browse files
author
MacroFake
committed
Move ::fCheckpointsEnabled into ChainstateManager
1 parent cccca83 commit fa43188

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/init.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
935935
init::SetLoggingLevel(args);
936936

937937
fCheckBlockIndex = args.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
938-
fCheckpointsEnabled = args.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED);
939938

940939
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
941940
int64_t nPruneArg = args.GetIntArg("-prune", 0);

src/kernel/chainstatemanager_opts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
class CChainParams;
1717

18+
static constexpr bool DEFAULT_CHECKPOINTS_ENABLED{true};
1819
static constexpr auto DEFAULT_MAX_TIP_AGE{24h};
1920

2021
namespace kernel {
@@ -27,6 +28,7 @@ namespace kernel {
2728
struct ChainstateManagerOpts {
2829
const CChainParams& chainparams;
2930
const std::function<NodeClock::time_point()> adjusted_time_callback{nullptr};
31+
bool checkpoints_enabled{DEFAULT_CHECKPOINTS_ENABLED};
3032
//! If set, it will override the minimum work we will assume exists on some valid chain.
3133
std::optional<arith_uint256> minimum_chain_work;
3234
//! If set, it will override the block hash whose ancestors we will assume to have valid scripts without checking them.

src/node/chainstatemanager_args.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
namespace node {
2020
std::optional<bilingual_str> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts)
2121
{
22+
if (auto value{args.GetBoolArg("-checkpoints")}) opts.checkpoints_enabled = *value;
23+
2224
if (auto value{args.GetArg("-minimumchainwork")}) {
2325
if (!IsHexNumber(*value)) {
2426
return strprintf(Untranslated("Invalid non-hex (%s) minimum chain work value specified"), *value);

src/validation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ std::condition_variable g_best_block_cv;
122122
uint256 g_best_block;
123123
bool g_parallel_script_checks{false};
124124
bool fCheckBlockIndex = false;
125-
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED;
126125

127126
const CBlockIndex* Chainstate::FindForkInGlobalIndex(const CBlockLocator& locator) const
128127
{
@@ -3528,7 +3527,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
35283527
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "bad-diffbits", "incorrect proof of work");
35293528

35303529
// Check against checkpoints
3531-
if (fCheckpointsEnabled) {
3530+
if (chainman.m_options.checkpoints_enabled) {
35323531
// Don't accept any forks from the main chain prior to last checkpoint.
35333532
// GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our
35343533
// BlockIndex().

src/validation.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ struct Params;
6363
static const int MAX_SCRIPTCHECK_THREADS = 15;
6464
/** -par default (number of script-checking threads, 0 = auto) */
6565
static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
66-
static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
6766
/** Default for -stopatheight */
6867
static const int DEFAULT_STOPATHEIGHT = 0;
6968
/** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ActiveChain().Tip() will not be pruned. */
@@ -97,7 +96,6 @@ extern uint256 g_best_block;
9796
*/
9897
extern bool g_parallel_script_checks;
9998
extern bool fCheckBlockIndex;
100-
extern bool fCheckpointsEnabled;
10199

102100
/** Documentation for argument 'checklevel'. */
103101
extern const std::vector<std::string> CHECKLEVEL_DOC;

0 commit comments

Comments
 (0)