Add getlocalsolps and getnetworksolps RPC calls, show them in getmininginfo
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
CCriticalSection cs_metrics;
|
||||
|
||||
boost::synchronized_value<int64_t> nNodeStartTime;
|
||||
AtomicCounter transactionsValidated;
|
||||
AtomicCounter ehSolverRuns;
|
||||
AtomicCounter solutionTargetChecks;
|
||||
@@ -39,6 +40,26 @@ void TrackMinedBlock(uint256 hash)
|
||||
trackedBlocks->push_back(hash);
|
||||
}
|
||||
|
||||
void MarkStartTime()
|
||||
{
|
||||
*nNodeStartTime = GetTime();
|
||||
}
|
||||
|
||||
int64_t GetUptime()
|
||||
{
|
||||
return GetTime() - *nNodeStartTime;
|
||||
}
|
||||
|
||||
double GetLocalSolPS_INTERNAL(int64_t uptime)
|
||||
{
|
||||
return uptime > 0 ? (double)solutionTargetChecks.get() / uptime : 0;
|
||||
}
|
||||
|
||||
double GetLocalSolPS()
|
||||
{
|
||||
return GetLocalSolPS_INTERNAL(GetUptime());
|
||||
}
|
||||
|
||||
static bool metrics_ThreadSafeMessageBox(const std::string& message,
|
||||
const std::string& caption,
|
||||
unsigned int style)
|
||||
@@ -118,13 +139,13 @@ int printMiningStatus(bool mining)
|
||||
return lines;
|
||||
}
|
||||
|
||||
int printMetrics(size_t cols, int64_t nStart, bool mining)
|
||||
int printMetrics(size_t cols, bool mining)
|
||||
{
|
||||
// Number of lines that are always displayed
|
||||
int lines = 3;
|
||||
|
||||
// Calculate uptime
|
||||
int64_t uptime = GetTime() - nStart;
|
||||
int64_t uptime = GetUptime();
|
||||
int days = uptime / (24 * 60 * 60);
|
||||
int hours = (uptime - (days * 24 * 60 * 60)) / (60 * 60);
|
||||
int minutes = (uptime - (((days * 24) + hours) * 60 * 60)) / 60;
|
||||
@@ -148,7 +169,7 @@ int printMetrics(size_t cols, int64_t nStart, bool mining)
|
||||
std::cout << "- " << strprintf(_("You have validated %d transactions!"), transactionsValidated.get()) << std::endl;
|
||||
|
||||
if (mining && loaded) {
|
||||
double solps = uptime > 0 ? (double)solutionTargetChecks.get() / uptime : 0;
|
||||
double solps = GetLocalSolPS_INTERNAL(uptime);
|
||||
std::string strSolps = strprintf("%.4f Sol/s", solps);
|
||||
std::cout << "- " << strprintf(_("You have contributed %s on average to the network solution rate."), strSolps) << std::endl;
|
||||
std::cout << "- " << strprintf(_("You have completed %d Equihash solver runs."), ehSolverRuns.get()) << std::endl;
|
||||
@@ -260,9 +281,6 @@ void ThreadShowMetricsScreen()
|
||||
std::cout << _("You're helping to strengthen the network and contributing to a social good :)") << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
// Count uptime
|
||||
int64_t nStart = GetTime();
|
||||
|
||||
while (true) {
|
||||
// Number of lines that are always displayed
|
||||
int lines = 1;
|
||||
@@ -287,7 +305,7 @@ void ThreadShowMetricsScreen()
|
||||
lines += printNetworkStats();
|
||||
}
|
||||
lines += printMiningStatus(mining);
|
||||
lines += printMetrics(cols, nStart, mining);
|
||||
lines += printMetrics(cols, mining);
|
||||
lines += printMessageBox(cols);
|
||||
lines += printInitMessage();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user