Skip to content

Commit aca0c00

Browse files
committed
Merge pull request #6905
a6efc01 Bugfix: Omit wallet-related options from -help when wallet is disabled (Luke Dashjr) 5f9260f Bugfix: If genproclimit is omitted to RPC setgenerate, don't change it; also show correct default in getmininginfo (Luke Dashjr) 420a82f Bugfix: Describe dblogsize option correctly (it refers to the wallet database, not memory pool) (Luke Dashjr) caa3d42 Bugfix: RPC: blockchain: Display correct defaults in help for verifychain method (Luke Dashjr)
2 parents 42f339e + a6efc01 commit aca0c00

File tree

7 files changed

+27
-16
lines changed

7 files changed

+27
-16
lines changed

src/init.cpp

Lines changed: 13 additions & 9 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
{
@@ -407,12 +407,16 @@ std::string HelpMessage(HelpMessageMode mode)
407407
if (showDebug)
408408
{
409409
strUsage += HelpMessageOpt("-checkpoints", strprintf("Disable expensive verification for known chain history (default: %u)", 1));
410-
strUsage += HelpMessageOpt("-dblogsize=<n>", strprintf("Flush database activity from memory pool to disk log every <n> megabytes (default: %u)", 100));
410+
#ifdef ENABLE_WALLET
411+
strUsage += HelpMessageOpt("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE));
412+
#endif
411413
strUsage += HelpMessageOpt("-disablesafemode", strprintf("Disable safemode, override a real safe mode event (default: %u)", 0));
412414
strUsage += HelpMessageOpt("-testsafemode", strprintf("Force safe mode (default: %u)", 0));
413415
strUsage += HelpMessageOpt("-dropmessagestest=<n>", "Randomly drop 1 of every <n> network messages");
414416
strUsage += HelpMessageOpt("-fuzzmessagestest=<n>", "Randomly fuzz 1 of every <n> network messages");
417+
#ifdef ENABLE_WALLET
415418
strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", 1));
419+
#endif
416420
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
417421
strUsage += HelpMessageOpt("-limitancestorcount=<n>", strprintf("Do not accept transactions if number of in-mempool ancestors is <n> or more (default: %u)", DEFAULT_ANCESTOR_LIMIT));
418422
strUsage += HelpMessageOpt("-limitancestorsize=<n>", strprintf("Do not accept transactions whose size with all in-mempool ancestors exceeds <n> kilobytes (default: %u)", DEFAULT_ANCESTOR_SIZE_LIMIT));
@@ -425,7 +429,7 @@ std::string HelpMessage(HelpMessageMode mode)
425429
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
426430
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + _("<category> can be:") + " " + debugCategories + ".");
427431
strUsage += HelpMessageOpt("-gen", strprintf(_("Generate coins (default: %u)"), 0));
428-
strUsage += HelpMessageOpt("-genproclimit=<n>", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), 1));
432+
strUsage += HelpMessageOpt("-genproclimit=<n>", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), DEFAULT_GENERATE_THREADS));
429433
strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)"));
430434
strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), 0));
431435
strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), 1));
@@ -1289,9 +1293,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12891293
}
12901294

12911295
uiInterface.InitMessage(_("Verifying blocks..."));
1292-
if (fHavePruned && GetArg("-checkblocks", 288) > MIN_BLOCKS_TO_KEEP) {
1296+
if (fHavePruned && GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) {
12931297
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
1294-
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
1298+
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", DEFAULT_CHECKBLOCKS));
12951299
}
12961300

12971301
{
@@ -1305,8 +1309,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
13051309
}
13061310
}
13071311

1308-
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
1309-
GetArg("-checkblocks", 288))) {
1312+
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", DEFAULT_CHECKLEVEL),
1313+
GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
13101314
strLoadError = _("Corrupted block database detected");
13111315
break;
13121316
}
@@ -1573,7 +1577,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
15731577
scheduler.scheduleEvery(f, nPowTargetSpacing);
15741578

15751579
// Generate coins in the background
1576-
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 1), Params());
1580+
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", DEFAULT_GENERATE_THREADS), Params());
15771581

15781582
// ********************************************************* Step 12: finished
15791583

src/main.h

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

130+
static const signed int DEFAULT_CHECKBLOCKS = MIN_BLOCKS_TO_KEEP;
131+
static const unsigned int DEFAULT_CHECKLEVEL = 3;
132+
130133
// Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat)
131134
// At 1MB per block, 288 blocks = 288MB.
132135
// Add 15% for Undo data = 331MB

src/miner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class CScript;
1717
class CWallet;
1818
namespace Consensus { struct Params; };
1919

20+
static const int DEFAULT_GENERATE_THREADS = 1;
21+
2022
struct CBlockTemplate
2123
{
2224
CBlock block;

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)

src/rpcmining.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
211211
if (params.size() > 0)
212212
fGenerate = params[0].get_bool();
213213

214-
int nGenProcLimit = -1;
214+
int nGenProcLimit = GetArg("-genproclimit", DEFAULT_GENERATE_THREADS);
215215
if (params.size() > 1)
216216
{
217217
nGenProcLimit = params[1].get_int();
@@ -259,7 +259,7 @@ UniValue getmininginfo(const UniValue& params, bool fHelp)
259259
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
260260
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
261261
obj.push_back(Pair("errors", GetWarnings("statusbar")));
262-
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
262+
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", DEFAULT_GENERATE_THREADS)));
263263
obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
264264
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
265265
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));

src/wallet/db.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void CDB::Flush()
293293
if (fReadOnly)
294294
nMinutes = 1;
295295

296-
bitdb.dbenv->txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100) * 1024 : 0, nMinutes, 0);
296+
bitdb.dbenv->txn_checkpoint(nMinutes ? GetArg("-dblogsize", DEFAULT_WALLET_DBLOGSIZE) * 1024 : 0, nMinutes, 0);
297297
}
298298

299299
void CDB::Close()

src/wallet/db.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
#include <db_cxx.h>
2222

23+
static const unsigned int DEFAULT_WALLET_DBLOGSIZE = 100;
24+
2325
extern unsigned int nWalletDBUpdated;
2426

2527
class CDBEnv

0 commit comments

Comments
 (0)