Force update average hashrates when print_status() is called

This commit is contained in:
SChernykh 2021-08-30 17:50:09 +02:00
parent d1e94d6e1a
commit 891ee36e53
2 changed files with 9 additions and 7 deletions

View file

@ -338,6 +338,12 @@ uint64_t StratumServer::get_random64()
return m_rng(); return m_rng();
} }
void StratumServer::print_status()
{
update_hashrate_data(0);
print_stratum_status();
}
void StratumServer::print_stratum_status() const void StratumServer::print_stratum_status() const
{ {
uint64_t hashes_15m, hashes_1h, hashes_24h, total_hashes; 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) void StratumServer::update_hashrate_data(uint64_t target)
{ {
if (target <= 1) {
return;
}
const time_t timestamp = time(nullptr); const time_t timestamp = time(nullptr);
uint64_t hashes, rem; uint64_t rem;
hashes = udiv128(1, 0, target, &rem); const uint64_t hashes = (target > 1) ? udiv128(1, 0, target, &rem) : 0;
WriteLock lock(m_hashrateDataLock); WriteLock lock(m_hashrateDataLock);

View file

@ -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); 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(); uint64_t get_random64();
void print_status() override { print_stratum_status(); } void print_status() override;
private: private:
void print_stratum_status() const; void print_stratum_status() const;