From 2b0309e1591a4a804b666af5d9d105f509028ad5 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 29 Apr 2018 14:24:44 +0700 Subject: [PATCH] Sync changes with proxy. --- src/common/crypto/Algorithm.cpp | 34 +++++++++++++++++++++++++++++++++ src/common/crypto/Algorithm.h | 9 +++++++++ src/common/log/Log.h | 2 ++ src/core/Config.cpp | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/common/crypto/Algorithm.cpp b/src/common/crypto/Algorithm.cpp index 168468f48..f3e9b23d1 100644 --- a/src/common/crypto/Algorithm.cpp +++ b/src/common/crypto/Algorithm.cpp @@ -71,6 +71,19 @@ static AlgoData const algorithms[] = { }; +#ifdef XMRIG_PROXY_PROJECT +static AlgoData const xmrStakAlgorithms[] = { + { "cryptonight-monerov7", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_1 }, + { "cryptonight_v7", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_1 }, + { "cryptonight_v7_stellite", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_XTL }, + { "cryptonight_lite", nullptr, xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_0 }, + { "cryptonight-aeonv7", nullptr, xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 }, + { "cryptonight_lite_v7", nullptr, xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 }, + { "cryptonight_lite_v7_xor", nullptr, xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_IPBC }, +}; +#endif + + static const char *variants[] = { "0", "1", @@ -163,6 +176,27 @@ void xmrig::Algorithm::setAlgo(Algo algo) } +#ifdef XMRIG_PROXY_PROJECT +void xmrig::Algorithm::parseXmrStakAlgorithm(const char *algo) +{ + m_algo = INVALID_ALGO; + m_variant = VARIANT_AUTO; + + for (size_t i = 0; i < ARRAY_SIZE(xmrStakAlgorithms); i++) { + if (strcasecmp(algo, xmrStakAlgorithms[i].name) == 0) { + m_algo = xmrStakAlgorithms[i].algo; + m_variant = xmrStakAlgorithms[i].variant; + break; + } + } + + if (m_algo == INVALID_ALGO) { + assert(false); + } +} +#endif + + const char *xmrig::Algorithm::name(bool shortName) const { for (size_t i = 0; i < ARRAY_SIZE(algorithms); i++) { diff --git a/src/common/crypto/Algorithm.h b/src/common/crypto/Algorithm.h index a34d5c07c..bcf029d8f 100644 --- a/src/common/crypto/Algorithm.h +++ b/src/common/crypto/Algorithm.h @@ -49,6 +49,11 @@ public: setAlgo(algo); } + inline Algorithm(const char *algo) + { + 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); } @@ -66,6 +71,10 @@ public: void parseVariant(int variant); void setAlgo(Algo algo); +# ifdef XMRIG_PROXY_PROJECT + void parseXmrStakAlgorithm(const char *algo); +# endif + private: const char *name(bool shortName) const; diff --git a/src/common/log/Log.h b/src/common/log/Log.h index 0b3332721..463c2248d 100644 --- a/src/common/log/Log.h +++ b/src/common/log/Log.h @@ -80,6 +80,8 @@ private: }; +#define RED_BOLD(x) "\e[1;31m" x "\e[0m" +#define RED(x) "\e[0;31m" x "\e[0m" #define GREEN_BOLD(x) "\e[1;32m" x "\e[0m" #define GREEN(x) "\e[0;32m" x "\e[0m" #define MAGENTA_BOLD(x) "\e[1;35m" x "\e[0m" diff --git a/src/core/Config.cpp b/src/core/Config.cpp index a27dc9172..0c4ce7794 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -102,7 +102,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const Value pools(kArrayType); - for (const Pool &pool : m_pools) { + for (const Pool &pool : m_activePools) { pools.PushBack(pool.toJSON(doc), allocator); }