aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/chainparams.cpp1
-rw-r--r--src/chainparams.h3
-rw-r--r--src/miner.cpp5
-rw-r--r--src/rpcmining.cpp2
4 files changed, 7 insertions, 4 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index ff104e7c84..d7205fa5cb 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -247,6 +247,7 @@ public:
virtual bool RequireRPCPassword() const { return false; }
virtual bool MiningRequiresPeers() const { return false; }
+ virtual bool MineBlocksOnDemand() const { return true; }
virtual Network NetworkID() const { return CChainParams::REGTEST; }
};
static CRegTestParams regTestParams;
diff --git a/src/chainparams.h b/src/chainparams.h
index a73279fe67..d76b1a2280 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -62,6 +62,9 @@ public:
/* Make miner wait to have peers to avoid wasting work */
virtual bool MiningRequiresPeers() const { return true; }
const string& DataDir() const { return strDataDir; }
+ /* Make miner stop after a block is found. In RPC, don't return
+ * until nGenProcLimit blocks are generated */
+ virtual bool MineBlocksOnDemand() const { return false; }
virtual Network NetworkID() const = 0;
const vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
const std::vector<unsigned char> &Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
diff --git a/src/miner.cpp b/src/miner.cpp
index 3d46a0d83e..e980fdc42d 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -580,9 +580,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;
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 23876c603d..70adae1467 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -174,7 +174,7 @@ Value setgenerate(const Array& params, bool fHelp)
}
// -regtest mode: don't return until nGenProcLimit blocks are generated
- if (fGenerate && Params().NetworkID() == CChainParams::REGTEST)
+ if (fGenerate && Params().MineBlocksOnDemand())
{
int nHeightStart = 0;
int nHeightEnd = 0;