diff --git a/src/metrics.cpp b/src/metrics.cpp index 8b41b5bfc..4d339b919 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -16,6 +16,7 @@ AtomicCounter transactionsValidated; AtomicCounter ehSolverRuns; +AtomicCounter solutionTargetChecks; AtomicCounter minedBlocks; boost::synchronized_value> messageBox; @@ -111,8 +112,11 @@ int printMetrics(size_t cols, int64_t nStart, bool mining) std::cout << "- " << strprintf(_("You have validated %d transactions."), transactionsValidated.get()) << std::endl; if (mining) { + double hps = uptime > 0 ? (double)solutionTargetChecks.get() / uptime : 0; + std::string strHps = strprintf("%.4f H/s", hps); + std::cout << "- " << strprintf(_("You have contributed %s on average to the network hash rate."), strHps) << std::endl; std::cout << "- " << strprintf(_("You have completed %d Equihash solver runs."), ehSolverRuns.get()) << std::endl; - lines++; + lines += 2; int mined = minedBlocks.get(); if (mined > 0) { diff --git a/src/metrics.h b/src/metrics.h index 5d8cca0dc..4a2ca2264 100644 --- a/src/metrics.h +++ b/src/metrics.h @@ -25,6 +25,7 @@ struct AtomicCounter { extern AtomicCounter transactionsValidated; extern AtomicCounter ehSolverRuns; +extern AtomicCounter solutionTargetChecks; extern AtomicCounter minedBlocks; void ConnectMetricsScreen(); diff --git a/src/miner.cpp b/src/miner.cpp index 2a5c070b8..bde9babd5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -541,6 +541,7 @@ void static BitcoinMiner(CWallet *pwallet) // Write the solution to the hash and compute the result. LogPrint("pow", "- Checking solution against target\n"); pblock->nSolution = soln; + solutionTargetChecks.increment(); if (UintToArith256(pblock->GetHash()) > hashTarget) { return false; diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 935d2b201..faa02b6db 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -192,6 +192,7 @@ Value generate(const Array& params, bool fHelp) std::function)> validBlock = [&pblock](std::vector soln) { pblock->nSolution = soln; + solutionTargetChecks.increment(); return CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus()); }; bool found = EhBasicSolveUncancellable(n, k, curr_state, validBlock);