Skip to content

Commit 5f9260f

Browse files
committed
Bugfix: If genproclimit is omitted to RPC setgenerate, don't change it; also show correct default in getmininginfo
1 parent 420a82f commit 5f9260f

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ std::string HelpMessage(HelpMessageMode mode)
422422
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
423423
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + _("<category> can be:") + " " + debugCategories + ".");
424424
strUsage += HelpMessageOpt("-gen", strprintf(_("Generate coins (default: %u)"), 0));
425-
strUsage += HelpMessageOpt("-genproclimit=<n>", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), 1));
425+
strUsage += HelpMessageOpt("-genproclimit=<n>", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), DEFAULT_GENERATE_THREADS));
426426
strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)"));
427427
strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), 0));
428428
strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), 1));
@@ -1558,7 +1558,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
15581558
scheduler.scheduleEvery(f, nPowTargetSpacing);
15591559

15601560
// Generate coins in the background
1561-
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 1), Params());
1561+
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", DEFAULT_GENERATE_THREADS), Params());
15621562

15631563
// ********************************************************* Step 12: finished
15641564

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/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()));

0 commit comments

Comments
 (0)