mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge pull request #3824
f0a83fcUse Params().NetworkID() instead of TestNet() from the payment protocol (jtimon)2871889net.h was using std namespace through chainparams.h included in protocol.h (jtimon)c8c52deReplace virtual methods with static attributes, chainparams.h depends on protocol.h instead of the other way around (jtimon)a3d946eGet rid of TestNet() (jtimon)6fc0fa6Add RPCisTestNet chain parameter (jtimon)cfeb823Add RequireStandard chain parameter (jtimon)21913a9Add AllowMinDifficultyBlocks chain parameter (jtimon)d754f34Move majority constants to chainparams (jtimon) 8d26721 Get rid of RegTest() (jtimon)cb9bd83Add DefaultCheckMemPool chain parameter (jtimon)2595b9aAdd DefaultMinerThreads chain parameter (jtimon)bfa9a1aAdd MineBlocksOnDemand chain parameter (jtimon)1712adbAdd MiningRequiresPeers chain parameter (jtimon)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user