Skip to content

Commit

Permalink
Add MineBlocksOnDemand chain parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimon committed Jun 4, 2014
1 parent 1712adb commit bfa9a1a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/chainparams.cpp
Expand Up @@ -247,6 +247,7 @@ class CRegTestParams : public CTestNetParams {

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;
Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.h
Expand Up @@ -62,6 +62,9 @@ class CChainParams
/* 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]; }
Expand Down
5 changes: 2 additions & 3 deletions src/miner.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/rpcmining.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit bfa9a1a

Please sign in to comment.