diff --git a/src/net/Client.cpp b/src/net/Client.cpp index 9c7f373ea..b01483366 100644 --- a/src/net/Client.cpp +++ b/src/net/Client.cpp @@ -237,6 +237,10 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code) return false; } + if (params.HasMember("coin")) { + job.setCoin(params["coin"].GetString()); + } + if (m_job == job) { if (!m_quiet) { LOG_WARN("[%s:%u] duplicate job received, reconnect", m_url.host(), m_url.port()); diff --git a/src/net/Job.cpp b/src/net/Job.cpp index 5820581f2..3faed6a18 100644 --- a/src/net/Job.cpp +++ b/src/net/Job.cpp @@ -65,6 +65,7 @@ Job::Job(int poolId, bool nicehash, bool monero) : m_diff(0), m_target(0) { + memset(m_coin, 0, sizeof(m_coin)); } @@ -148,6 +149,18 @@ bool Job::setTarget(const char *target) } +void Job::setCoin(const char *coin) +{ + if (!coin || strlen(coin) > 4) { + memset(m_coin, 0, sizeof(m_coin)); + return; + } + + strncpy(m_coin, coin, sizeof(m_coin)); + m_monero = strcmp(m_coin, "XMR") == 0; +} + + bool Job::fromHex(const char* in, unsigned int len, unsigned char* out) { bool error = false; diff --git a/src/net/Job.h b/src/net/Job.h index dc87eb8cd..755de9ec4 100644 --- a/src/net/Job.h +++ b/src/net/Job.h @@ -42,11 +42,13 @@ public: bool setBlob(const char *blob); bool setTarget(const char *target); + void setCoin(const char *coin); inline bool isMonero() const { return m_monero; } inline bool isNicehash() const { return m_nicehash; } inline bool isValid() const { return m_size > 0 && m_diff > 0; } inline bool setId(const char *id) { return m_id.setId(id); } + inline const char *coin() const { return m_coin; } inline const uint32_t *nonce() const { return reinterpret_cast(m_blob + 39); } inline const uint8_t *blob() const { return m_blob; } inline const xmrig::Id &id() const { return m_id; } @@ -77,6 +79,7 @@ private: bool m_monero; bool m_nicehash; + char m_coin[5]; int m_poolId; int m_threadId; size_t m_size;