Skip to content

Commit

Permalink
Add DefaultMinerThreads chain parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimon committed Jun 4, 2014
1 parent bfa9a1a commit 2595b9a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class CMainParams : public CChainParams {
nRPCPort = 8332;
bnProofOfWorkLimit = ~uint256(0) >> 32;
nSubsidyHalvingInterval = 210000;
nMinerThreads = 0;

// Build the genesis block. Note that the output of the genesis coinbase cannot
// be spent as it did not originally exist in the database.
Expand Down Expand Up @@ -233,6 +234,7 @@ class CRegTestParams : public CTestNetParams {
pchMessageStart[2] = 0xb5;
pchMessageStart[3] = 0xda;
nSubsidyHalvingInterval = 150;
nMinerThreads = 1;
bnProofOfWorkLimit = ~uint256(0) >> 1;
genesis.nTime = 1296688602;
genesis.nBits = 0x207fffff;
Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class CChainParams
int GetDefaultPort() const { return nDefaultPort; }
const uint256& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
int SubsidyHalvingInterval() const { return nSubsidyHalvingInterval; }
/* Used if GenerateBitcoins is called with a negative number of threads */
int DefaultMinerThreads() const { return nMinerThreads; }
virtual const CBlock& GenesisBlock() const = 0;
virtual bool RequireRPCPassword() const { return true; }
/* Make miner wait to have peers to avoid wasting work */
Expand All @@ -82,6 +84,7 @@ class CChainParams
uint256 bnProofOfWorkLimit;
int nSubsidyHalvingInterval;
string strDataDir;
int nMinerThreads;
vector<CDNSSeedData> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
};
Expand Down
5 changes: 3 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,9 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
static boost::thread_group* minerThreads = NULL;

if (nThreads < 0) {
if (Params().NetworkID() == CChainParams::REGTEST)
nThreads = 1;
// In regtest threads defaults to 1
if (Params().DefaultMinerThreads())
nThreads = Params().DefaultMinerThreads();
else
nThreads = boost::thread::hardware_concurrency();
}
Expand Down

0 comments on commit 2595b9a

Please sign in to comment.