diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-05-12 16:36:23 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-05-12 16:37:19 +0200 |
commit | 484821870b5a92f64d3075cfd30757ea8bd29739 (patch) | |
tree | a55a61b01b20483e91ba3671e2f8809495c8e4d6 /src | |
parent | 40de49c3584001b43d7e2c7d8dfc02dbcf470d41 (diff) | |
parent | bba7c249296a9a2f444e1035fef8f8b593ba2aaf (diff) |
Merge pull request #6123
bba7c24 Avoid crash on start in TestBlockValidity with gen=1. (Gregory Maxwell)
Diffstat (limited to 'src')
-rw-r--r-- | src/miner.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/miner.cpp b/src/miner.cpp index 56a2c5828b..4bceb7d7b4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -453,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); } // @@ -533,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) |