Auto merge of #4572 - oxarbitrage:issue4571, r=str4d

Add solution rates aproximation to metrics

Closes https://github.com/zcash/zcash/issues/4571
This commit is contained in:
Homu 2020-07-10 07:02:14 +00:00
commit 66d4c88943
1 changed files with 7 additions and 2 deletions

View File

@ -276,6 +276,7 @@ int printStats(bool isScreen, bool mining)
int64_t currentHeadersTime;
size_t connections;
int64_t netsolps;
double netsolpsLog = 1.0;
const Consensus::Params& params = Params().GetConsensus();
{
LOCK2(cs_main, cs_vNodes);
@ -284,8 +285,12 @@ int printStats(bool isScreen, bool mining)
currentHeadersTime = pindexBestHeader ? pindexBestHeader->nTime : 0;
connections = vNodes.size();
netsolps = GetNetworkHashPS(120, -1);
netsolpsLog = std::log2(netsolps);
}
auto localsolps = GetLocalSolPS();
double localsolpsLog = 0.0;
if (localsolps > 0)
localsolpsLog = std::log2(localsolps);
if (IsInitialBlockDownload(Params())) {
if (fReindex) {
@ -342,9 +347,9 @@ int printStats(bool isScreen, bool mining)
}
std::cout << " " << _("Next upgrade") << " | " << strUpgradeTime << std::endl;
std::cout << " " << _("Connections") << " | " << connections << std::endl;
std::cout << " " << _("Network solution rate") << " | " << netsolps << " Sol/s" << std::endl;
std::cout << " " << _("Network solution rate") << " | " << strprintf("~ 2^%.4f Sol/s", netsolpsLog) << std::endl;
if (mining && miningTimer.running()) {
std::cout << " " << _("Local solution rate") << " | " << strprintf("%.4f Sol/s", localsolps) << std::endl;
std::cout << " " << _("Local solution rate") << " | " << strprintf("~ 2^%.4f Sol/s", localsolpsLog) << std::endl;
lines++;
}
std::cout << std::endl;