Skip to content

Commit caa3d42

Browse files
committed
Bugfix: RPC: blockchain: Display correct defaults in help for verifychain method
1 parent da894ab commit caa3d42

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/init.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ std::string HelpMessage(HelpMessageMode mode)
307307
strUsage += HelpMessageOpt("-alerts", strprintf(_("Receive and display P2P network alerts (default: %u)"), DEFAULT_ALERTS));
308308
strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
309309
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
310-
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288));
311-
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3));
310+
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS));
311+
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), DEFAULT_CHECKLEVEL));
312312
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "bitcoin.conf"));
313313
if (mode == HMM_BITCOIND)
314314
{
@@ -1273,9 +1273,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12731273
}
12741274

12751275
uiInterface.InitMessage(_("Verifying blocks..."));
1276-
if (fHavePruned && GetArg("-checkblocks", 288) > MIN_BLOCKS_TO_KEEP) {
1276+
if (fHavePruned && GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) {
12771277
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
1278-
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
1278+
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", DEFAULT_CHECKBLOCKS));
12791279
}
12801280

12811281
{
@@ -1289,8 +1289,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12891289
}
12901290
}
12911291

1292-
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
1293-
GetArg("-checkblocks", 288))) {
1292+
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", DEFAULT_CHECKLEVEL),
1293+
GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
12941294
strLoadError = _("Corrupted block database detected");
12951295
break;
12961296
}

src/main.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ extern uint64_t nPruneTarget;
123123
/** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of chainActive.Tip() will not be pruned. */
124124
static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
125125

126+
static const signed int DEFAULT_CHECKBLOCKS = MIN_BLOCKS_TO_KEEP;
127+
static const unsigned int DEFAULT_CHECKLEVEL = 3;
128+
126129
// Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat)
127130
// At 1MB per block, 288 blocks = 288MB.
128131
// Add 15% for Undo data = 331MB

src/rpcblockchain.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,15 @@ UniValue gettxout(const UniValue& params, bool fHelp)
539539

540540
UniValue verifychain(const UniValue& params, bool fHelp)
541541
{
542+
int nCheckLevel = GetArg("-checklevel", DEFAULT_CHECKLEVEL);
543+
int nCheckDepth = GetArg("-checkblocks", DEFAULT_CHECKBLOCKS);
542544
if (fHelp || params.size() > 2)
543545
throw runtime_error(
544546
"verifychain ( checklevel numblocks )\n"
545547
"\nVerifies blockchain database.\n"
546548
"\nArguments:\n"
547-
"1. checklevel (numeric, optional, 0-4, default=3) How thorough the block verification is.\n"
548-
"2. numblocks (numeric, optional, default=288, 0=all) The number of blocks to check.\n"
549+
"1. checklevel (numeric, optional, 0-4, default=" + strprintf("%d", nCheckLevel) + ") How thorough the block verification is.\n"
550+
"2. numblocks (numeric, optional, default=" + strprintf("%d", nCheckDepth) + ", 0=all) The number of blocks to check.\n"
549551
"\nResult:\n"
550552
"true|false (boolean) Verified or not\n"
551553
"\nExamples:\n"
@@ -555,8 +557,6 @@ UniValue verifychain(const UniValue& params, bool fHelp)
555557

556558
LOCK(cs_main);
557559

558-
int nCheckLevel = GetArg("-checklevel", 3);
559-
int nCheckDepth = GetArg("-checkblocks", 288);
560560
if (params.size() > 0)
561561
nCheckLevel = params[0].get_int();
562562
if (params.size() > 1)

0 commit comments

Comments
 (0)