stats: don't report network.*hashesPerSecond if it's zero

It's more likely that the stat is broken than the network running with
such low difficulty, the hash rate is reported as zero.
`*hashesPerSecond` are a gauge and we should let the last known good
value linger instead of potentially overwriting it with an improbable
value.
This commit is contained in:
Kittywhiskers Van Gogh 2024-12-08 10:18:13 +00:00
parent b39c6b9909
commit 40070c0337
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -866,10 +866,12 @@ static void PeriodicStats(NodeContext& node)
return workDiff.getdouble() / timeDiff; return workDiff.getdouble() / timeDiff;
}(); }();
::g_stats_client->gaugeDouble("network.hashesPerSecond", nNetworkHashPS); if (nNetworkHashPS > 0.0) {
::g_stats_client->gaugeDouble("network.terahashesPerSecond", nNetworkHashPS / 1e12); ::g_stats_client->gaugeDouble("network.hashesPerSecond", nNetworkHashPS);
::g_stats_client->gaugeDouble("network.petahashesPerSecond", nNetworkHashPS / 1e15); ::g_stats_client->gaugeDouble("network.terahashesPerSecond", nNetworkHashPS / 1e12);
::g_stats_client->gaugeDouble("network.exahashesPerSecond", nNetworkHashPS / 1e18); ::g_stats_client->gaugeDouble("network.petahashesPerSecond", nNetworkHashPS / 1e15);
::g_stats_client->gaugeDouble("network.exahashesPerSecond", nNetworkHashPS / 1e18);
}
// No need for cs_main, we never use null tip here // No need for cs_main, we never use null tip here
::g_stats_client->gaugeDouble("network.difficulty", (double)GetDifficulty(tip)); ::g_stats_client->gaugeDouble("network.difficulty", (double)GetDifficulty(tip));