Skip to content

Commit 2595b9a

Browse files
committed
Add DefaultMinerThreads chain parameter
1 parent bfa9a1a commit 2595b9a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/chainparams.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class CMainParams : public CChainParams {
112112
nRPCPort = 8332;
113113
bnProofOfWorkLimit = ~uint256(0) >> 32;
114114
nSubsidyHalvingInterval = 210000;
115+
nMinerThreads = 0;
115116

116117
// Build the genesis block. Note that the output of the genesis coinbase cannot
117118
// be spent as it did not originally exist in the database.
@@ -233,6 +234,7 @@ class CRegTestParams : public CTestNetParams {
233234
pchMessageStart[2] = 0xb5;
234235
pchMessageStart[3] = 0xda;
235236
nSubsidyHalvingInterval = 150;
237+
nMinerThreads = 1;
236238
bnProofOfWorkLimit = ~uint256(0) >> 1;
237239
genesis.nTime = 1296688602;
238240
genesis.nBits = 0x207fffff;

src/chainparams.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class CChainParams
5757
int GetDefaultPort() const { return nDefaultPort; }
5858
const uint256& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
5959
int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
60+
/* Used if GenerateBitcoins is called with a negative number of threads */
61+
int DefaultMinerThreads() const { return nMinerThreads; }
6062
virtual const CBlock& GenesisBlock() const = 0;
6163
virtual bool RequireRPCPassword() const { return true; }
6264
/* Make miner wait to have peers to avoid wasting work */
@@ -82,6 +84,7 @@ class CChainParams
8284
uint256 bnProofOfWorkLimit;
8385
int nSubsidyHalvingInterval;
8486
string strDataDir;
87+
int nMinerThreads;
8588
vector<CDNSSeedData> vSeeds;
8689
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
8790
};

src/miner.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,9 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
652652
static boost::thread_group* minerThreads = NULL;
653653

654654
if (nThreads < 0) {
655-
if (Params().NetworkID() == CChainParams::REGTEST)
656-
nThreads = 1;
655+
// In regtest threads defaults to 1
656+
if (Params().DefaultMinerThreads())
657+
nThreads = Params().DefaultMinerThreads();
657658
else
658659
nThreads = boost::thread::hardware_concurrency();
659660
}

0 commit comments

Comments
 (0)