aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-06-09 12:47:12 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-09 12:52:29 +0200
commit62fdf381fa707206140f80e010e15de23ca3c8fd (patch)
tree74481380f2eea8a6ea74a6273136019e80eba108 /src/miner.cpp
parent07b233a1b6e5f15ac7c8b3343088d1b2f3c8e1f1 (diff)
parentf0a83fc256023f68cc046bd096de69f16ce9d394 (diff)
Merge pull request #3824
f0a83fc Use Params().NetworkID() instead of TestNet() from the payment protocol (jtimon) 2871889 net.h was using std namespace through chainparams.h included in protocol.h (jtimon) c8c52de Replace virtual methods with static attributes, chainparams.h depends on protocol.h instead of the other way around (jtimon) a3d946e Get rid of TestNet() (jtimon) 6fc0fa6 Add RPCisTestNet chain parameter (jtimon) cfeb823 Add RequireStandard chain parameter (jtimon) 21913a9 Add AllowMinDifficultyBlocks chain parameter (jtimon) d754f34 Move majority constants to chainparams (jtimon) 8d26721 Get rid of RegTest() (jtimon) cb9bd83 Add DefaultCheckMemPool chain parameter (jtimon) 2595b9a Add DefaultMinerThreads chain parameter (jtimon) bfa9a1a Add MineBlocksOnDemand chain parameter (jtimon) 1712adb Add MiningRequiresPeers chain parameter (jtimon)
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index baaa22c8f3..68abc4a6ef 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -514,7 +514,7 @@ void static BitcoinMiner(CWallet *pwallet)
unsigned int nExtraNonce = 0;
try { while (true) {
- if (Params().NetworkID() != CChainParams::REGTEST) {
+ if (Params().MiningRequiresPeers()) {
// Busy-wait for the network to come online so we don't waste time mining
// on an obsolete chain. In regtest mode we expect to fly solo.
while (vNodes.empty())
@@ -582,9 +582,8 @@ void static BitcoinMiner(CWallet *pwallet)
CheckWork(pblock, *pwallet, reservekey);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
- // In regression test mode, stop mining after a block is found. This
- // allows developers to controllably generate a block on demand.
- if (Params().NetworkID() == CChainParams::REGTEST)
+ // In regression test mode, stop mining after a block is found.
+ if (Params().MineBlocksOnDemand())
throw boost::thread_interrupted();
break;
@@ -622,7 +621,8 @@ void static BitcoinMiner(CWallet *pwallet)
// Check for stop or if block needs to be rebuilt
boost::this_thread::interruption_point();
- if (vNodes.empty() && Params().NetworkID() != CChainParams::REGTEST)
+ // Regtest mode doesn't require peers
+ if (vNodes.empty() && Params().MiningRequiresPeers())
break;
if (nBlockNonce >= 0xffff0000)
break;
@@ -634,7 +634,7 @@ void static BitcoinMiner(CWallet *pwallet)
// Update nTime every few seconds
UpdateTime(*pblock, pindexPrev);
nBlockTime = ByteReverse(pblock->nTime);
- if (TestNet())
+ if (Params().AllowMinDifficultyBlocks())
{
// Changing pblock->nTime can change work required on testnet:
nBlockBits = ByteReverse(pblock->nBits);
@@ -654,8 +654,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();
}