aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index 3abd2d68e4..4bceb7d7b4 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -7,6 +7,7 @@
#include "amount.h"
#include "chainparams.h"
+#include "consensus/consensus.h"
#include "hash.h"
#include "main.h"
#include "net.h"
@@ -452,8 +453,16 @@ void static BitcoinMiner(CWallet *pwallet)
if (chainparams.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())
+ do {
+ bool fvNodesEmpty;
+ {
+ LOCK(cs_vNodes);
+ fvNodesEmpty = vNodes.empty();
+ }
+ if (!fvNodesEmpty && !IsInitialBlockDownload())
+ break;
MilliSleep(1000);
+ } while (true);
}
//
@@ -532,6 +541,11 @@ void static BitcoinMiner(CWallet *pwallet)
LogPrintf("BitcoinMiner terminated\n");
throw;
}
+ catch (const std::runtime_error &e)
+ {
+ LogPrintf("BitcoinMiner runtime error: %s\n", e.what());
+ return;
+ }
}
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)