mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-05-17 23:56:39 +00:00
Avoid crash on start in TestBlockValidity with gen=1.
When the internal miner is enabled at the start of a new node, there is an near instant assert in TestBlockValidity because its attempting to mine a block before the top checkpoint. Also avoids a data race around vNodes. Github-Pull: #6123 Rebased-From: bba7c249296a9a2f444e1035fef8f8b593ba2aaf
This commit is contained in:
parent
49e4d14f75
commit
da656068ec
@ -456,8 +456,16 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
if (Params().MiningRequiresPeers()) {
|
if (Params().MiningRequiresPeers()) {
|
||||||
// Busy-wait for the network to come online so we don't waste time mining
|
// 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.
|
// 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);
|
MilliSleep(1000);
|
||||||
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -570,6 +578,11 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
LogPrintf("BitcoinMiner terminated\n");
|
LogPrintf("BitcoinMiner terminated\n");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
catch (const std::runtime_error &e)
|
||||||
|
{
|
||||||
|
LogPrintf("BitcoinMiner runtime error: %s\n", e.what());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
|
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user