From 891ee36e53fa25cda8291123887c012ebaeb2652 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Mon, 30 Aug 2021 17:50:09 +0200 Subject: [PATCH] Force update average hashrates when print_status() is called --- src/stratum_server.cpp | 14 ++++++++------ src/stratum_server.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/stratum_server.cpp b/src/stratum_server.cpp index d62cf16..8a575d7 100644 --- a/src/stratum_server.cpp +++ b/src/stratum_server.cpp @@ -338,6 +338,12 @@ uint64_t StratumServer::get_random64() return m_rng(); } +void StratumServer::print_status() +{ + update_hashrate_data(0); + print_stratum_status(); +} + void StratumServer::print_stratum_status() const { uint64_t hashes_15m, hashes_1h, hashes_24h, total_hashes; @@ -478,14 +484,10 @@ void StratumServer::on_blobs_ready() void StratumServer::update_hashrate_data(uint64_t target) { - if (target <= 1) { - return; - } - const time_t timestamp = time(nullptr); - uint64_t hashes, rem; - hashes = udiv128(1, 0, target, &rem); + uint64_t rem; + const uint64_t hashes = (target > 1) ? udiv128(1, 0, target, &rem) : 0; WriteLock lock(m_hashrateDataLock); diff --git a/src/stratum_server.h b/src/stratum_server.h index dd4b4c9..af42948 100644 --- a/src/stratum_server.h +++ b/src/stratum_server.h @@ -70,7 +70,7 @@ public: bool on_submit(StratumClient* client, uint32_t id, const char* job_id_str, const char* nonce_str, const char* result_str); uint64_t get_random64(); - void print_status() override { print_stratum_status(); } + void print_status() override; private: void print_stratum_status() const;