Skip to content

Commit eec8608

Browse files
author
Mark Erhardt
committed
Move CheckBlockIndex to validation.cpp
The global fCheckBlockIndex is only used once and has no interaction.
1 parent a7aec7a commit eec8608

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

src/init.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,6 @@ bool AppInitParameterInteraction()
10091009
if (ratio != 0) {
10101010
mempool.setSanityCheck(1.0 / ratio);
10111011
}
1012-
fCheckBlockIndex = gArgs.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
10131012
fCheckpointsEnabled = gArgs.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED);
10141013

10151014
hashAssumeValid = uint256S(gArgs.GetArg("-assumevalid", chainparams.GetConsensus().defaultAssumeValid.GetHex()));
@@ -1133,6 +1132,8 @@ bool AppInitParameterInteraction()
11331132

11341133
nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
11351134

1135+
ValidationParameterInteraction(chainparams);
1136+
11361137
return true;
11371138
}
11381139

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
6868
fs::create_directories(m_path_root);
6969
gArgs.ForceSetArg("-datadir", m_path_root.string());
7070
ClearDatadirCache();
71+
gArgs.ForceSetArg("-checkblockindex", "1");
7172
SelectParams(chainName);
7273
SeedInsecureRand();
7374
gArgs.ForceSetArg("-printtoconsole", "0");
@@ -79,7 +80,6 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
7980
SetupNetworking();
8081
InitSignatureCache();
8182
InitScriptExecutionCache();
82-
fCheckBlockIndex = true;
8383
static bool noui_connected = false;
8484
if (!noui_connected) {
8585
noui_connect();

src/validation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
180180

181181
std::unique_ptr<CBlockTreeDB> pblocktree;
182182

183+
void ValidationParameterInteraction(const CChainParams& chainparams)
184+
{
185+
fCheckBlockIndex = gArgs.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
186+
}
187+
183188
// See definition for documentation
184189
static void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight);
185190
static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight);

src/validation.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ extern std::atomic_bool fReindex;
152152
*/
153153
extern bool g_parallel_script_checks;
154154
extern bool fRequireStandard;
155-
extern bool fCheckBlockIndex;
156155
extern bool fCheckpointsEnabled;
157156
extern size_t nCoinCacheUsage;
158157
/** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
@@ -293,6 +292,9 @@ int VersionBitsTipStateSinceHeight(const Consensus::Params& params, Consensus::D
293292
/** Apply the effects of this transaction on the UTXO set represented by view */
294293
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
295294

295+
/** Parse and validate parameters only used in validation.cpp */
296+
void ValidationParameterInteraction(const CChainParams& chainparams);
297+
296298
/** Transaction validation functions */
297299

298300
/**

0 commit comments

Comments
 (0)