Added support for "rig id" protocol extension.

This commit is contained in:
XMRig 2018-04-23 13:20:43 +07:00
parent 6d40f2dd1a
commit b9fec2fcc4
10 changed files with 38 additions and 11 deletions

View file

@ -177,6 +177,10 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
m_pools.back().setPassword(arg);
break;
case RigIdKey: /* --rig-id */
m_pools.back().setRigId(arg);
break;
case LogFileKey: /* --log-file */
m_logFile = arg;
break;

View file

@ -80,8 +80,12 @@ private:
};
#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"
#define MAGENTA(x) "\e[0;35m" x "\e[0m"
#define CYAN_BOLD(x) "\e[1;36m" x "\e[0m"
#define CYAN(x) "\e[0;36m" x "\e[0m"
#define WHITE_BOLD(x) "\e[1;37m" x "\e[0m"
#define WHITE(x) "\e[0;37m" x "\e[0m"

View file

@ -397,6 +397,10 @@ void Client::login()
params.AddMember("pass", rapidjson::StringRef(m_pool.password()), allocator);
params.AddMember("agent", rapidjson::StringRef(m_agent), allocator);
if (m_pool.rigId()) {
params.AddMember("rigid", rapidjson::StringRef(m_pool.rigId()), allocator);
}
doc.AddMember("params", params, allocator);
rapidjson::StringBuffer buffer(0, 512);

View file

@ -177,6 +177,7 @@ bool Pool::isEqual(const Pool &other) const
&& m_algorithm == other.m_algorithm
&& m_host == other.m_host
&& m_password == other.m_password
&& m_rigId == other.m_rigId
&& m_url == other.m_url
&& m_user == other.m_user
&& m_variant == other.m_variant);
@ -254,9 +255,14 @@ void Pool::adjust(xmrig::Algo algorithm)
if (strstr(m_host.data(), ".nicehash.com")) {
m_keepAlive = false;
m_nicehash = true;
if (strstr(m_host.data(), "cryptonightv7.")) {
m_variant = xmrig::VARIANT_V1;
}
}
if (strstr(m_host.data(), ".minergate.com")) {
m_variant = xmrig::VARIANT_V1;
m_keepAlive = false;
}
}
@ -303,6 +309,7 @@ void Pool::print() const
LOG_DEBUG ("port: %d", static_cast<int>(m_port));
LOG_DEBUG ("user: %s", m_user.data());
LOG_DEBUG ("pass: %s", m_password.data());
LOG_DEBUG ("rig_id %s", m_rigId.data());
LOG_DEBUG ("algo: %s/%d", algoName(m_algorithm), static_cast<int>(variant()));
LOG_DEBUG ("nicehash: %d", static_cast<int>(m_nicehash));
LOG_DEBUG ("keepAlive: %d", m_keepAlive);

View file

@ -58,6 +58,7 @@ public:
inline bool isValid() const { return !m_host.isNull() && m_port > 0; }
inline const char *host() const { return m_host.data(); }
inline const char *password() const { return !m_password.isNull() ? m_password.data() : kDefaultPassword; }
inline const char *rigId() const { return m_rigId.data(); }
inline const char *url() const { return m_url.data(); }
inline const char *user() const { return !m_user.isNull() ? m_user.data() : kDefaultUser; }
inline int keepAlive() const { return m_keepAlive; }
@ -67,6 +68,7 @@ public:
inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; }
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
inline void setPassword(const char *password) { m_password = password; }
inline void setRigId(const char *rigId) { m_rigId = rigId; }
inline void setUser(const char *user) { m_user = user; }
inline xmrig::Algo algorithm() const { return m_algorithm; }
@ -93,6 +95,7 @@ private:
xmrig::Algo m_algorithm;
xmrig::c_str m_host;
xmrig::c_str m_password;
xmrig::c_str m_rigId;
xmrig::c_str m_url;
xmrig::c_str m_user;
xmrig::Variant m_variant;