From eb5b582e1fedb2afe12c80add36c2e199e6058ec Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sun, 30 Oct 2016 15:25:40 -0700 Subject: [PATCH] Add network stats to metrics screen Closes #1688 --- src/metrics.cpp | 20 +++++++++++++++++++- src/rpcmining.cpp | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/metrics.cpp b/src/metrics.cpp index 580c88f6e..cfc5c987b 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -28,6 +28,8 @@ boost::synchronized_value> messageBox; boost::synchronized_value initMessage; bool loaded = false; +extern int64_t GetNetworkHashPS(int lookup, int height); + void TrackMinedBlock(uint256 hash) { minedBlocks.increment(); @@ -74,6 +76,18 @@ void ConnectMetricsScreen() uiInterface.InitMessage.connect(metrics_InitMessage); } +int printNetworkStats() +{ + LOCK2(cs_main, cs_vNodes); + + std::cout << " " << _("Block height") << " | " << chainActive.Height() << std::endl; + std::cout << " " << _("Network solution rate") << " | " << GetNetworkHashPS(120, -1) << " Sol/s" << std::endl; + std::cout << " " << _("Connections") << " | " << vNodes.size() << std::endl; + std::cout << std::endl; + + return 4; +} + int printMiningStatus(bool mining) { // Number of lines that are always displayed @@ -88,7 +102,8 @@ int printMiningStatus(bool mining) else nThreads = boost::thread::hardware_concurrency(); } - std::cout << strprintf(_("You are running %d mining threads."), nThreads) << std::endl; + std::cout << strprintf(_("You are mining with the %s solver on %d threads."), + GetArg("-equihashsolver", "default"), nThreads) << std::endl; lines++; } else { std::cout << _("You are currently not mining.") << std::endl; @@ -258,6 +273,9 @@ void ThreadShowMetricsScreen() // Miner status bool mining = GetBoolArg("-gen", false); + if (loaded) { + lines += printNetworkStats(); + } lines += printMiningStatus(mining); lines += printMetrics(cols, nStart, mining); lines += printMessageBox(cols); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index a23d6b991..af34c291c 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -37,7 +37,7 @@ using namespace std; * or over the difficulty averaging window if 'lookup' is nonpositive. * If 'height' is nonnegative, compute the estimate at the time when a given block was found. */ -Value GetNetworkHashPS(int lookup, int height) { +int64_t GetNetworkHashPS(int lookup, int height) { CBlockIndex *pb = chainActive.Tip(); if (height >= 0 && height < chainActive.Height())