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

@ -132,8 +132,8 @@ static void print_pools(xmrig::Config *config)
}
# ifdef APP_DEBUG
for (size_t i = 0; i < pools.size(); ++i) {
Log::i()->text("%s:%d, user: %s, pass: %s, ka: %d, nicehash: %d", pools[i].host(), pools[i].port(), pools[i].user(), pools[i].password(), pools[i].keepAlive(), pools[i].isNicehash());
for (const Pool &pool : pools) {
pool.print();
}
# endif
}

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;

View file

@ -108,6 +108,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
obj.AddMember("url", StringRef(pool.url()), allocator);
obj.AddMember("user", StringRef(pool.user()), allocator);
obj.AddMember("pass", StringRef(pool.password()), allocator);
obj.AddMember("rig-id", pool.rigId() ? Value(StringRef(pool.rigId())).Move() : Value(kNullType).Move(), allocator);
if (pool.keepAlive() == 0 || pool.keepAlive() == Pool::kKeepAliveTimeout) {
obj.AddMember("keepalive", pool.keepAlive() > 0, allocator);

View file

@ -58,6 +58,7 @@ Options:\n\
-O, --userpass=U:P username:password pair for mining server\n\
-u, --user=USERNAME username for mining server\n\
-p, --pass=PASSWORD password for mining server\n\
--rig-id=ID rig identifier for pool-side statistics (needs pool support)\n\
-t, --threads=N number of miner threads\n\
-v, --av=N algorithm variation, 0 auto select\n\
-k, --keepalive send keepalived for prevent timeout (need pool support)\n\
@ -128,6 +129,7 @@ static struct option const options[] = {
{ "user", 1, nullptr, xmrig::IConfig::UserKey },
{ "user-agent", 1, nullptr, xmrig::IConfig::UserAgentKey },
{ "userpass", 1, nullptr, xmrig::IConfig::UserpassKey },
{ "rig-id", 1, nullptr, xmrig::IConfig::RigIdKey },
{ "version", 0, nullptr, xmrig::IConfig::VersionKey },
{ 0, 0, 0, 0 }
};
@ -165,6 +167,7 @@ static struct option const pool_options[] = {
{ "nicehash", 0, nullptr, xmrig::IConfig::NicehashKey },
{ "keepalive", 2, nullptr, xmrig::IConfig::KeepAliveKey },
{ "variant", 1, nullptr, xmrig::IConfig::VariantKey },
{ "rig-id", 1, nullptr, xmrig::IConfig::RigIdKey },
{ 0, 0, 0, 0 }
};

View file

@ -36,30 +36,31 @@ public:
enum Keys {
// common
AlgorithmKey = 'a',
ApiPort = 4000,
ApiAccessTokenKey = 4001,
ApiWorkerIdKey = 4002,
ApiIPv6Key = 4003,
ApiPort = 4000,
ApiRestrictedKey = 4004,
ApiWorkerIdKey = 4002,
BackgroundKey = 'B',
ColorKey = 1002,
ConfigKey = 'c',
DonateLevelKey = 1003,
HelpKey = 'h',
KeepAliveKey = 'k',
LogFileKey = 'l',
ColorKey = 1002,
WatchKey = 1105,
PasswordKey = 'p',
RetriesKey = 'r',
RetryPauseKey = 'R',
RigIdKey = 1012,
SyslogKey = 'S',
UrlKey = 'o',
UserKey = 'u',
UserAgentKey = 1008,
UserKey = 'u',
UserpassKey = 'O',
VariantKey = 1010,
VerboseKey = 1100,
VersionKey = 'V',
VariantKey = 1010,
WatchKey = 1105,
// xmrig common
CPUPriorityKey = 1021,

View file

@ -133,7 +133,7 @@ void Workers::start(xmrig::Controller *controller)
{
const std::vector<xmrig::IThread *> &threads = controller->config()->threads();
m_status.algo = controller->config()->algorithm();
m_status.colors = controller->config()->isHugePages();
m_status.colors = controller->config()->isColors();
m_status.threads = threads.size();
for (const xmrig::IThread *thread : threads) {
@ -301,9 +301,9 @@ void Workers::start(IWorker *worker)
const size_t memory = m_status.ways * xmrig::cn_select_memory(m_status.algo) / 1048576;
if (m_status.colors) {
LOG_INFO("\x1B[01;32mREADY (CPU)\x1B[0m threads \x1B[01;36m%zu(%zu)\x1B[0m huge pages %s%zu/%zu %1.0f%%\x1B[0m memory \x1B[01;36m%zu.0 MB",
LOG_INFO(GREEN_BOLD("READY (CPU)") " threads " CYAN_BOLD("%zu(%zu)") " huge pages %s%zu/%zu %1.0f%%\e[0m memory " CYAN_BOLD("%zu.0 MB") "",
m_status.threads, m_status.ways,
(m_status.hugePages == m_status.pages ? "\x1B[01;32m" : (m_status.hugePages == 0 ? "\x1B[01;31m" : "\x1B[01;33m")),
(m_status.hugePages == m_status.pages ? "\e[1;32m" : (m_status.hugePages == 0 ? "\e[1;31m" : "\e[1;33m")),
m_status.hugePages, m_status.pages, percent, memory);
}
else {