From dd2812f1e53eee04b453fad512f4a79960904c87 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:19:10 +0100 Subject: [PATCH] Fixed data race --- src/stratum_server.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/stratum_server.cpp b/src/stratum_server.cpp index 169fee5..902ff35 100644 --- a/src/stratum_server.cpp +++ b/src/stratum_server.cpp @@ -888,7 +888,10 @@ void StratumServer::update_hashrate_data(uint64_t hashes, uint64_t timestamp) WriteLock lock(m_hashrateDataLock); - m_cumulativeHashes += hashes; + if (hashes) { + m_cumulativeHashes += hashes; + ++m_totalStratumShares; + } HashrateData* data = m_hashrateData; HashrateData& head = data[m_hashrateDataHead]; @@ -1094,10 +1097,6 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/) server->ban(share->m_clientIPv6, share->m_clientAddr, DEFAULT_BAN_TIME); } - if (share->m_result == SubmittedShare::Result::OK) { - ++server->m_totalStratumShares; - } - if (share->m_allocated) { auto it = std::find(server->m_pendingShareChecks.begin(), server->m_pendingShareChecks.end(), share); if (it != server->m_pendingShareChecks.end()) {