diff --git a/src/common/crypto/Algorithm.cpp b/src/common/crypto/Algorithm.cpp index 909c772ab..2f2593726 100644 --- a/src/common/crypto/Algorithm.cpp +++ b/src/common/crypto/Algorithm.cpp @@ -150,10 +150,16 @@ void xmrig::Algorithm::parseAlgorithm(const char *algo) m_variant = VARIANT_AUTO; assert(algo != nullptr); - if (algo == nullptr) { + if (algo == nullptr || strlen(algo) < 1) { return; } + if (*algo == '!') { + m_flags |= Forced; + + return parseAlgorithm(algo + 1); + } + for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) { if ((strcasecmp(algo, algorithms[i].name) == 0) || (strcasecmp(algo, algorithms[i].shortName) == 0)) { m_algo = algorithms[i].algo; @@ -172,6 +178,16 @@ void xmrig::Algorithm::parseVariant(const char *variant) { m_variant = VARIANT_AUTO; + if (variant == nullptr || strlen(variant) < 1) { + return; + } + + if (*variant == '!') { + m_flags |= Forced; + + return parseVariant(variant + 1); + } + for (size_t i = 0; i < ARRAY_SIZE(variants); i++) { if (strcasecmp(variant, variants[i]) == 0) { m_variant = static_cast(i); diff --git a/src/common/crypto/Algorithm.h b/src/common/crypto/Algorithm.h index 4a975ad1e..f4380d45f 100644 --- a/src/common/crypto/Algorithm.h +++ b/src/common/crypto/Algorithm.h @@ -39,28 +39,38 @@ namespace xmrig { class Algorithm { public: + enum Flags { + None = 0, + Forced = 1 + }; + inline Algorithm() : m_algo(INVALID_ALGO), + m_flags(0), m_variant(VARIANT_AUTO) {} inline Algorithm(Algo algo, Variant variant) : + m_flags(0), m_variant(variant) { setAlgo(algo); } - inline Algorithm(const char *algo) + inline Algorithm(const char *algo) : + m_flags(0) { parseAlgorithm(algo); } - bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; } - inline Algo algo() const { return m_algo; } - inline const char *name() const { return name(false); } - inline const char *shortName() const { return name(true); } - inline Variant variant() const { return m_variant; } - inline void setVariant(Variant variant) { m_variant = variant; } + inline Algo algo() const { return m_algo; } + inline bool isEqual(const Algorithm &other) const { return m_algo == other.m_algo && m_variant == other.m_variant; } + inline bool isForced() const { return m_flags & Forced; } + inline const char *name() const { return name(false); } + inline const char *shortName() const { return name(true); } + inline int flags() const { return m_flags; } + inline Variant variant() const { return m_variant; } + inline void setVariant(Variant variant) { m_variant = variant; } inline bool operator!=(const Algorithm &other) const { return !isEqual(other); } inline bool operator==(const Algorithm &other) const { return isEqual(other); } @@ -80,6 +90,7 @@ private: const char *name(bool shortName) const; Algo m_algo; + int m_flags; Variant m_variant; }; diff --git a/src/common/net/Job.cpp b/src/common/net/Job.cpp index 2eb84f187..7da2ed83b 100644 --- a/src/common/net/Job.cpp +++ b/src/common/net/Job.cpp @@ -124,11 +124,14 @@ bool Job::setBlob(const char *blob) if (m_autoVariant) { m_algorithm.setVariant(variant()); } - else if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) { - m_algorithm.setVariant(xmrig::VARIANT_HALF); - } - else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) { - m_algorithm.setVariant(xmrig::VARIANT_HALF); + + if (!m_algorithm.isForced()) { + if (m_algorithm.variant() == xmrig::VARIANT_XTL && m_blob[0] >= 9) { + m_algorithm.setVariant(xmrig::VARIANT_HALF); + } + else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) { + m_algorithm.setVariant(xmrig::VARIANT_HALF); + } } # ifdef XMRIG_PROXY_PROJECT