Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115812
D9941.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D9941.diff
View Options
diff --git a/src/rpc/mining.h b/src/rpc/mining.h
new file mode 100644
--- /dev/null
+++ b/src/rpc/mining.h
@@ -0,0 +1,14 @@
+// Copyright (c) 2020 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_RPC_MINING_H
+#define BITCOIN_RPC_MINING_H
+
+/**
+ * Default max iterations to try in RPC generatetodescriptor,
+ * generatetoaddress, and generateblock.
+ */
+static const uint64_t DEFAULT_MAX_TRIES{1000000};
+
+#endif // BITCOIN_RPC_MINING_H
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -22,6 +22,7 @@
#include <policy/policy.h>
#include <pow/pow.h>
#include <rpc/blockchain.h>
+#include <rpc/mining.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <script/descriptor.h>
@@ -246,7 +247,8 @@
"How many blocks are generated immediately."},
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO,
"The descriptor to send the newly generated bitcoin to."},
- {"maxtries", RPCArg::Type::NUM, /* default */ "1000000",
+ {"maxtries", RPCArg::Type::NUM,
+ /* default */ ToString(DEFAULT_MAX_TRIES),
"How many iterations to try."},
},
RPCResult{RPCResult::Type::ARR,
@@ -261,8 +263,9 @@
.Check(request);
const int num_blocks{request.params[0].get_int()};
- const int64_t max_tries{
- request.params[2].isNull() ? 1000000 : request.params[2].get_int()};
+ const uint64_t max_tries{request.params[2].isNull()
+ ? DEFAULT_MAX_TRIES
+ : request.params[2].get_int()};
CScript coinbase_script;
std::string error;
@@ -289,7 +292,8 @@
"How many blocks are generated immediately."},
{"address", RPCArg::Type::STR, RPCArg::Optional::NO,
"The address to send the newly generated bitcoin to."},
- {"maxtries", RPCArg::Type::NUM, /* default */ "1000000",
+ {"maxtries", RPCArg::Type::NUM,
+ /* default */ ToString(DEFAULT_MAX_TRIES),
"How many iterations to try."},
},
RPCResult{RPCResult::Type::ARR,
@@ -308,7 +312,7 @@
.Check(request);
int nGenerate = request.params[0].get_int();
- uint64_t nMaxTries = 1000000;
+ uint64_t nMaxTries{DEFAULT_MAX_TRIES};
if (!request.params[2].isNull()) {
nMaxTries = request.params[2].get_int64();
}
@@ -452,7 +456,7 @@
}
BlockHash block_hash;
- uint64_t max_tries{1000000};
+ uint64_t max_tries{DEFAULT_MAX_TRIES};
unsigned int extra_nonce{0};
if (!GenerateBlock(config, EnsureChainman(request.context), block,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 12:09 (58 m, 33 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187790
Default Alt Text
D9941.diff (2 KB)
Attached To
D9941: rpc: create rpc/mining.h, hoist default max tries values to constant
Event Timeline
Log In to Comment