From de6ee749fed1cf6a8dba4edc0309064c3f539a4f Mon Sep 17 00:00:00 2001 From: XMRig Date: Thu, 14 Jun 2018 23:49:30 +0700 Subject: [PATCH] #692 Add support for global algorithm variant. --- src/common/config/CommonConfig.cpp | 2 +- src/common/net/Pool.cpp | 21 +++++++++++++-------- src/common/net/Pool.h | 2 +- src/net/strategies/DonateStrategy.cpp | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/common/config/CommonConfig.cpp b/src/common/config/CommonConfig.cpp index 315b09d68..7e43b39de 100644 --- a/src/common/config/CommonConfig.cpp +++ b/src/common/config/CommonConfig.cpp @@ -123,7 +123,7 @@ bool xmrig::CommonConfig::finalize() } for (Pool &pool : m_pools) { - pool.adjust(m_algorithm.algo()); + pool.adjust(m_algorithm); if (pool.isValid() && pool.algorithm().isValid()) { m_activePools.push_back(std::move(pool)); diff --git a/src/common/net/Pool.cpp b/src/common/net/Pool.cpp index 806664a01..58be044e6 100644 --- a/src/common/net/Pool.cpp +++ b/src/common/net/Pool.cpp @@ -223,22 +223,27 @@ rapidjson::Value Pool::toJSON(rapidjson::Document &doc) const } -void Pool::adjust(xmrig::Algo algorithm) +void Pool::adjust(const xmrig::Algorithm &algorithm) { + using namespace xmrig; + if (!isValid()) { return; } if (!m_algorithm.isValid()) { - m_algorithm.setAlgo(algorithm); + m_algorithm.setAlgo(algorithm.algo()); # ifndef XMRIG_PROXY_PROJECT - if (m_algorithm.variant() == xmrig::VARIANT_AUTO) { - if (algorithm == xmrig::CRYPTONIGHT_HEAVY) { - m_algorithm.setVariant(xmrig::VARIANT_0); + if (m_algorithm.variant() == VARIANT_AUTO) { + if (algorithm.variant() != VARIANT_AUTO) { + m_algorithm.setVariant(algorithm.variant()); + } + else if (algorithm.algo() == CRYPTONIGHT_HEAVY) { + m_algorithm.setVariant(VARIANT_0); } else { - m_algorithm.setVariant(xmrig::VARIANT_1); + m_algorithm.setVariant(VARIANT_1); } } # endif @@ -249,13 +254,13 @@ void Pool::adjust(xmrig::Algo algorithm) m_nicehash = true; if (strstr(m_host.data(), "cryptonightv7.")) { - m_algorithm.setVariant(xmrig::VARIANT_1); + m_algorithm.setVariant(VARIANT_1); } } if (strstr(m_host.data(), ".minergate.com")) { m_keepAlive = false; - m_algorithm.setVariant(xmrig::VARIANT_1); + m_algorithm.setVariant(VARIANT_1); } rebuild(); diff --git a/src/common/net/Pool.h b/src/common/net/Pool.h index eaabe54d3..e6ecef4a3 100644 --- a/src/common/net/Pool.h +++ b/src/common/net/Pool.h @@ -77,7 +77,7 @@ public: bool parse(const char *url); bool setUserpass(const char *userpass); rapidjson::Value toJSON(rapidjson::Document &doc) const; - void adjust(xmrig::Algo algorithm); + void adjust(const xmrig::Algorithm &algorithm); void setAlgo(const xmrig::Algorithm &algorithm); # ifdef APP_DEBUG diff --git a/src/net/strategies/DonateStrategy.cpp b/src/net/strategies/DonateStrategy.cpp index 4d353655a..395c53bbf 100644 --- a/src/net/strategies/DonateStrategy.cpp +++ b/src/net/strategies/DonateStrategy.cpp @@ -68,7 +68,7 @@ DonateStrategy::DonateStrategy(int level, const char *user, xmrig::Algo algo, IS } for (Pool &pool : m_pools) { - pool.adjust(algo); + pool.adjust(xmrig::Algorithm(algo, xmrig::VARIANT_AUTO)); } if (m_pools.size() > 1) {