From b267c19a45e4dfc9eb396dd2308f92ceff04b55d Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 26 Jun 2022 17:06:21 +0200 Subject: [PATCH] Limit autodiff to 4M for max compatibility --- src/stratum_server.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/stratum_server.cpp b/src/stratum_server.cpp index 2d5dce8..56e1f40 100644 --- a/src/stratum_server.cpp +++ b/src/stratum_server.cpp @@ -251,6 +251,10 @@ bool StratumServer::on_login(StratumClient* client, uint32_t id, const char* log LOGINFO(5, "client " << log::Gray() << static_cast(client->m_addrString) << " set custom difficulty " << client->m_customDiff); target = std::max(target, client->m_customDiff.target()); } + else if (m_autoDiff) { + // Limit autodiff to 4000000 for maximum compatibility + target = std::max(target, TARGET_4_BYTES_LIMIT); + } if (get_custom_user(login, client->m_customUser)) { const char* s = client->m_customUser; @@ -686,6 +690,9 @@ void StratumServer::on_blobs_ready() target = std::max(target, client->m_customDiff.target()); } else if (m_autoDiff) { + // Limit autodiff to 4000000 for maximum compatibility + target = std::max(target, TARGET_4_BYTES_LIMIT); + if (client->m_autoDiff.lo) { const uint32_t k = client->m_autoDiffIndex; const uint16_t elapsed_time = static_cast(cur_time) - client->m_autoDiffData[(k - 1) % StratumClient::AUTO_DIFF_SIZE].m_timestamp;