diff --git a/src/Options.cpp b/src/Options.cpp index 4e7c75cac..f60b12858 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -4,8 +4,8 @@ * Copyright 2014 Lucas Jones <https://github.com/lucasjones> * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2016-2017 XMRig <support@xmrig.com> - * + * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> + * Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -74,6 +74,7 @@ Options:\n\ --cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\ --no-huge-pages disable huge pages support\n\ --no-color disable colored output\n\ + --no-monero disable Monero v7 PoW\n\ --donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\ --user-agent set custom user-agent string for pool\n\ -B, --background run the miner in the background\n\ @@ -118,6 +119,7 @@ static struct option const options[] = { { "nicehash", 0, nullptr, 1006 }, { "no-color", 0, nullptr, 1002 }, { "no-huge-pages", 0, nullptr, 1009 }, + { "no-monero", 0, nullptr, 1010 }, { "pass", 1, nullptr, 'p' }, { "print-time", 1, nullptr, 1007 }, { "retries", 1, nullptr, 'r' }, @@ -158,11 +160,12 @@ static struct option const config_options[] = { static struct option const pool_options[] = { - { "url", 1, nullptr, 'o' }, { "pass", 1, nullptr, 'p' }, + { "url", 1, nullptr, 'o' }, { "user", 1, nullptr, 'u' }, { "userpass", 1, nullptr, 'O' }, { "keepalive", 0, nullptr ,'k' }, + { "monero", 0, nullptr, 1010 }, { "nicehash", 0, nullptr, 1006 }, { 0, 0, 0, 0 } }; @@ -392,6 +395,7 @@ bool Options::parseArg(int key, const char *arg) case 1002: /* --no-color */ case 1009: /* --no-huge-pages */ + case 1010: /* --no-monero */ return parseBoolean(key, false); case 't': /* --threads */ @@ -557,6 +561,10 @@ bool Options::parseBoolean(int key, bool enable) m_hugePages = enable; break; + case 1010: /* monero */ + m_pools.back()->setMonero(enable); + break; + case 2000: /* colors */ m_colors = enable; break; diff --git a/src/Options.h b/src/Options.h index 6f0749179..625ac78d8 100644 --- a/src/Options.h +++ b/src/Options.h @@ -4,8 +4,8 @@ * Copyright 2014 Lucas Jones <https://github.com/lucasjones> * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2016-2017 XMRig <support@xmrig.com> - * + * Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt> + * Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/net/Client.cpp b/src/net/Client.cpp index d347ed22a..a023ef38e 100644 --- a/src/net/Client.cpp +++ b/src/net/Client.cpp @@ -220,7 +220,7 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code) return false; } - Job job(m_id, m_url.isNicehash()); + Job job(m_id, m_url.isNicehash(), m_url.isMonero()); if (!job.setId(params["job_id"].GetString())) { *code = 3; return false; diff --git a/src/net/Job.cpp b/src/net/Job.cpp index e0e49b435..5820581f2 100644 --- a/src/net/Job.cpp +++ b/src/net/Job.cpp @@ -56,7 +56,8 @@ static inline char hf_bin2hex(unsigned char c) } -Job::Job(int poolId, bool nicehash) : +Job::Job(int poolId, bool nicehash, bool monero) : + m_monero(monero), m_nicehash(nicehash), m_poolId(poolId), m_threadId(-1), diff --git a/src/net/Job.h b/src/net/Job.h index e2fe9f166..dc87eb8cd 100644 --- a/src/net/Job.h +++ b/src/net/Job.h @@ -37,12 +37,13 @@ class Job { public: - Job(int poolId = -2, bool nicehash = false); + Job(int poolId = -2, bool nicehash = false, bool monero = true); ~Job(); bool setBlob(const char *blob); bool setTarget(const char *target); + 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); } @@ -55,7 +56,7 @@ public: inline uint32_t *nonce() { return reinterpret_cast<uint32_t*>(m_blob + 39); } inline uint32_t diff() const { return (uint32_t) m_diff; } inline uint64_t target() const { return m_target; } - inline uint8_t version() const { return m_blob[0]; } + inline uint8_t version() const { return isMonero() ? m_blob[0] : 0; } inline void setNicehash(bool nicehash) { m_nicehash = nicehash; } inline void setThreadId(int threadId) { m_threadId = threadId; } @@ -74,6 +75,7 @@ public: private: VAR_ALIGN(16, uint8_t m_blob[84]); // Max blob size is 84 (75 fixed + 9 variable), aligned to 96. https://github.com/xmrig/xmrig/issues/1 Thanks fireice-uk. + bool m_monero; bool m_nicehash; int m_poolId; int m_threadId; diff --git a/src/net/Url.cpp b/src/net/Url.cpp index f58ca48af..cd020b322 100644 --- a/src/net/Url.cpp +++ b/src/net/Url.cpp @@ -37,6 +37,7 @@ Url::Url() : m_keepAlive(false), + m_monero(true), m_nicehash(false), m_host(nullptr), m_password(nullptr), @@ -60,6 +61,7 @@ Url::Url() : */ Url::Url(const char *url) : m_keepAlive(false), + m_monero(true), m_nicehash(false), m_host(nullptr), m_password(nullptr), @@ -71,8 +73,9 @@ Url::Url(const char *url) : } -Url::Url(const char *host, uint16_t port, const char *user, const char *password, bool keepAlive, bool nicehash) : +Url::Url(const char *host, uint16_t port, const char *user, const char *password, bool keepAlive, bool nicehash, bool monero) : m_keepAlive(keepAlive), + m_monero(monero), m_nicehash(nicehash), m_password(password ? strdup(password) : nullptr), m_user(user ? strdup(user) : nullptr), @@ -218,6 +221,7 @@ bool Url::operator==(const Url &other) const Url &Url::operator=(const Url *other) { m_keepAlive = other->m_keepAlive; + m_monero = other->m_monero; m_nicehash = other->m_nicehash; m_port = other->m_port; @@ -227,6 +231,11 @@ Url &Url::operator=(const Url *other) setPassword(other->m_password); setUser(other->m_user); + if (m_url) { + delete [] m_url; + m_url = nullptr; + } + return *this; } diff --git a/src/net/Url.h b/src/net/Url.h index 330f2d8e7..32eea5bfd 100644 --- a/src/net/Url.h +++ b/src/net/Url.h @@ -37,10 +37,11 @@ public: Url(); Url(const char *url); - Url(const char *host, uint16_t port, const char *user = nullptr, const char *password = nullptr, bool keepAlive = false, bool nicehash = false ); + Url(const char *host, uint16_t port, const char *user = nullptr, const char *password = nullptr, bool keepAlive = false, bool nicehash = false, bool monero = true); ~Url(); inline bool isKeepAlive() const { return m_keepAlive; } + inline bool isMonero() const { return m_monero; } inline bool isNicehash() const { return m_nicehash; } inline bool isValid() const { return m_host && m_port > 0; } inline const char *host() const { return m_host; } @@ -48,6 +49,7 @@ public: inline const char *user() const { return m_user ? m_user : kDefaultUser; } inline uint16_t port() const { return m_port; } inline void setKeepAlive(bool keepAlive) { m_keepAlive = keepAlive; } + inline void setMonero(bool monero) { m_monero = monero; } inline void setNicehash(bool nicehash) { m_nicehash = nicehash; } bool parse(const char *url); @@ -64,6 +66,7 @@ private: bool parseIPv6(const char *addr); bool m_keepAlive; + bool m_monero; bool m_nicehash; char *m_host; char *m_password;