Use AtomicTimer for more accurate local solution rate

This commit is contained in:
Jack Grigg
2017-03-23 12:37:22 +13:00
parent 73bf85b44f
commit 07be8f7eb9
3 changed files with 10 additions and 7 deletions

View File

@@ -528,12 +528,14 @@ void static BitcoinMiner()
cancelSolver = true;
}
);
miningTimer.start();
try {
while (true) {
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.
miningTimer.stop();
do {
bool fvNodesEmpty;
{
@@ -544,6 +546,7 @@ void static BitcoinMiner()
break;
MilliSleep(1000);
} while (true);
miningTimer.start();
}
//
@@ -721,16 +724,19 @@ void static BitcoinMiner()
}
catch (const boost::thread_interrupted&)
{
miningTimer.stop();
c.disconnect();
LogPrintf("ZcashMiner terminated\n");
throw;
}
catch (const std::runtime_error &e)
{
miningTimer.stop();
c.disconnect();
LogPrintf("ZcashMiner runtime error: %s\n", e.what());
return;
}
miningTimer.stop();
c.disconnect();
}