From 40816883a7c3f85f42e7afc35110eadee9635f5a Mon Sep 17 00:00:00 2001 From: XMRig Date: Tue, 12 Feb 2019 03:24:47 +0700 Subject: [PATCH] Sync changes. --- src/common/crypto/Algorithm.cpp | 5 ++++- src/common/net/Client.cpp | 12 ++++++++++++ src/common/net/Job.cpp | 17 ++++++++++++++--- src/common/net/Job.h | 3 +++ src/common/net/Pool.cpp | 1 + src/common/xmrig.h | 1 + 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/common/crypto/Algorithm.cpp b/src/common/crypto/Algorithm.cpp index 7bd0136..b64aed7 100644 --- a/src/common/crypto/Algorithm.cpp +++ b/src/common/crypto/Algorithm.cpp @@ -64,6 +64,8 @@ static AlgoData const algorithms[] = { { "cryptonight/2", "cn/2", xmrig::CRYPTONIGHT, xmrig::VARIANT_2 }, { "cryptonight/half", "cn/half", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF }, { "cryptonight/xtlv9", "cn/xtlv9", xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF }, + { "cryptonight/wow", "cn/wow", xmrig::CRYPTONIGHT, xmrig::VARIANT_WOW }, + { "cryptonight/r", "cn/r", xmrig::CRYPTONIGHT, xmrig::VARIANT_WOW }, # ifndef XMRIG_NO_AEON { "cryptonight-lite", "cn-lite", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_AUTO }, @@ -127,7 +129,8 @@ static const char *variants[] = { "2", "half", "trtl", - "gpu" + "gpu", + "wow", }; diff --git a/src/common/net/Client.cpp b/src/common/net/Client.cpp index 8458b1e..36ddba3 100644 --- a/src/common/net/Client.cpp +++ b/src/common/net/Client.cpp @@ -218,6 +218,10 @@ int64_t Client::submit(const JobResult &result) } # endif + if (m_job.algorithm().variant() == xmrig::VARIANT_WOW && m_job.id() != result.jobId) { + return -1; + } + using namespace rapidjson; # ifdef XMRIG_PROXY_PROJECT @@ -354,6 +358,14 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code) } } + if (params.HasMember("height")) { + const rapidjson::Value &variant = params["height"]; + + if (variant.IsUint64()) { + job.setHeight(variant.GetUint64()); + } + } + if (!verifyAlgorithm(job.algorithm())) { *code = 6; diff --git a/src/common/net/Job.cpp b/src/common/net/Job.cpp index 7da2ed8..ee76f73 100644 --- a/src/common/net/Job.cpp +++ b/src/common/net/Job.cpp @@ -31,7 +31,7 @@ #include "common/net/Job.h" -static inline unsigned char hf_hex2bin(char c, bool &err) +unsigned char hf_hex2bin(char c, bool &err) { if (c >= '0' && c <= '9') { return c - '0'; @@ -48,7 +48,7 @@ static inline unsigned char hf_hex2bin(char c, bool &err) } -static inline char hf_bin2hex(unsigned char c) +char hf_bin2hex(unsigned char c) { if (c <= 0x9) { return '0' + c; @@ -66,7 +66,8 @@ Job::Job() : m_size(0), m_diff(0), m_target(0), - m_blob() + m_blob(), + m_height(0) { } @@ -80,6 +81,7 @@ Job::Job(int poolId, bool nicehash, const xmrig::Algorithm &algorithm, const xmr m_diff(0), m_target(0), m_blob(), + m_height(0), m_algorithm(algorithm), m_clientId(clientId) { @@ -132,6 +134,9 @@ bool Job::setBlob(const char *blob) else if (m_algorithm.variant() == xmrig::VARIANT_MSR && m_blob[0] >= 8) { m_algorithm.setVariant(xmrig::VARIANT_HALF); } + else if (m_algorithm.variant() == xmrig::VARIANT_WOW && m_blob[0] < 11) { + m_algorithm.setVariant(xmrig::VARIANT_2); + } } # ifdef XMRIG_PROXY_PROJECT @@ -195,6 +200,12 @@ void Job::setAlgorithm(const char *algo) } +void Job::setHeight(uint64_t height) +{ + m_height = height; +} + + bool Job::fromHex(const char* in, unsigned int len, unsigned char* out) { bool error = false; diff --git a/src/common/net/Job.h b/src/common/net/Job.h index 398e99a..4fdac3a 100644 --- a/src/common/net/Job.h +++ b/src/common/net/Job.h @@ -50,6 +50,7 @@ public: bool setBlob(const char *blob); bool setTarget(const char *target); void setAlgorithm(const char *algo); + void setHeight(uint64_t height); inline bool isNicehash() const { return m_nicehash; } inline bool isValid() const { return m_size > 0 && m_diff > 0; } @@ -65,6 +66,7 @@ public: inline uint32_t *nonce() { return reinterpret_cast(m_blob + 39); } inline uint32_t diff() const { return static_cast(m_diff); } inline uint64_t target() const { return m_target; } + inline uint64_t height() const { return m_height; } inline void reset() { m_size = 0; m_diff = 0; } inline void setClientId(const xmrig::Id &id) { m_clientId = id; } inline void setPoolId(int poolId) { m_poolId = poolId; } @@ -100,6 +102,7 @@ private: uint64_t m_diff; uint64_t m_target; uint8_t m_blob[kMaxBlobSize]; + uint64_t m_height; xmrig::Algorithm m_algorithm; xmrig::Id m_clientId; xmrig::Id m_id; diff --git a/src/common/net/Pool.cpp b/src/common/net/Pool.cpp index ad1ac66..585e459 100644 --- a/src/common/net/Pool.cpp +++ b/src/common/net/Pool.cpp @@ -412,6 +412,7 @@ void Pool::rebuild() m_algorithms.push_back(m_algorithm); # ifndef XMRIG_PROXY_PROJECT + addVariant(xmrig::VARIANT_WOW); addVariant(xmrig::VARIANT_2); addVariant(xmrig::VARIANT_1); addVariant(xmrig::VARIANT_0); diff --git a/src/common/xmrig.h b/src/common/xmrig.h index 09bba08..c861d11 100644 --- a/src/common/xmrig.h +++ b/src/common/xmrig.h @@ -74,6 +74,7 @@ enum Variant { VARIANT_HALF = 9, // CryptoNight variant 2 with half iterations (Masari/Stellite) VARIANT_TRTL = 10, // CryptoNight Turtle (TRTL) VARIANT_GPU = 11, // CryptoNight-GPU (Ryo) + VARIANT_WOW = 12, // CryptoNightR (Wownero) VARIANT_MAX };