File tree Expand file tree Collapse file tree 3 files changed +6
-2
lines changed
Expand file tree Collapse file tree 3 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,7 @@ class CRegTestParams : public CTestNetParams {
246246 }
247247
248248 virtual bool RequireRPCPassword () const { return false ; }
249+ virtual bool MiningRequiresPeers () const { return false ; }
249250 virtual Network NetworkID () const { return CChainParams::REGTEST; }
250251};
251252static CRegTestParams regTestParams;
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ class CChainParams
5959 int SubsidyHalvingInterval () const { return nSubsidyHalvingInterval; }
6060 virtual const CBlock& GenesisBlock () const = 0;
6161 virtual bool RequireRPCPassword () const { return true ; }
62+ /* Make miner wait to have peers to avoid wasting work */
63+ virtual bool MiningRequiresPeers () const { return true ; }
6264 const string& DataDir () const { return strDataDir; }
6365 virtual Network NetworkID () const = 0;
6466 const vector<CDNSSeedData>& DNSSeeds () const { return vSeeds; }
Original file line number Diff line number Diff line change @@ -512,7 +512,7 @@ void static BitcoinMiner(CWallet *pwallet)
512512 unsigned int nExtraNonce = 0 ;
513513
514514 try { while (true ) {
515- if (Params ().NetworkID () != CChainParams::REGTEST ) {
515+ if (Params ().MiningRequiresPeers () ) {
516516 // Busy-wait for the network to come online so we don't waste time mining
517517 // on an obsolete chain. In regtest mode we expect to fly solo.
518518 while (vNodes.empty ())
@@ -620,7 +620,8 @@ void static BitcoinMiner(CWallet *pwallet)
620620
621621 // Check for stop or if block needs to be rebuilt
622622 boost::this_thread::interruption_point ();
623- if (vNodes.empty () && Params ().NetworkID () != CChainParams::REGTEST)
623+ // Regtest mode doesn't require peers
624+ if (vNodes.empty () && Params ().MiningRequiresPeers ())
624625 break ;
625626 if (nBlockNonce >= 0xffff0000 )
626627 break ;
You can’t perform that action at this time.
0 commit comments