From 914fdd5f0a344996f011ab9a8da213a5268822b6 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 6 Oct 2017 19:10:08 +0300 Subject: [PATCH] #97 Ignore keepalive option with minergate and nicehash.com --- src/Options.cpp | 4 ++++ src/api/ApiState.cpp | 2 +- src/net/Url.cpp | 24 ++++++++++++++++++------ src/net/Url.h | 3 ++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Options.cpp b/src/Options.cpp index 71c3a1808..bcc830d0c 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -261,6 +261,10 @@ Options::Options(int argc, char **argv) : } } + for (Url *url : m_pools) { + url->applyExceptions(); + } + m_ready = true; } diff --git a/src/api/ApiState.cpp b/src/api/ApiState.cpp index 3154307d9..bade355a3 100644 --- a/src/api/ApiState.cpp +++ b/src/api/ApiState.cpp @@ -57,7 +57,7 @@ static inline double normalize(double d) return 0.0; } - return std::floor(d * 10.0) / 10.0; + return std::floor(d * 100.0) / 100.0; } diff --git a/src/net/Url.cpp b/src/net/Url.cpp index a0024d261..dcbe82af5 100644 --- a/src/net/Url.cpp +++ b/src/net/Url.cpp @@ -24,6 +24,7 @@ #include #include +#include #include "net/Url.h" @@ -87,12 +88,6 @@ Url::~Url() } -bool Url::isNicehash() const -{ - return isValid() && (m_nicehash || strstr(m_host, ".nicehash.com")); -} - - bool Url::parse(const char *url) { const char *p = strstr(url, "://"); @@ -144,6 +139,23 @@ bool Url::setUserpass(const char *userpass) } +void Url::applyExceptions() +{ + if (!isValid()) { + return; + } + + if (strstr(m_host, ".nicehash.com")) { + m_keepAlive = false; + m_nicehash = true; + } + + if (strstr(m_host, ".minergate.com")) { + m_keepAlive = false; + } +} + + void Url::setPassword(const char *password) { if (!password) { diff --git a/src/net/Url.h b/src/net/Url.h index 43197195f..a1982300c 100644 --- a/src/net/Url.h +++ b/src/net/Url.h @@ -41,6 +41,7 @@ public: ~Url(); inline bool isKeepAlive() const { return m_keepAlive; } + 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; } inline const char *password() const { return m_password ? m_password : kDefaultPassword; } @@ -49,9 +50,9 @@ public: inline void setKeepAlive(bool keepAlive) { m_keepAlive = keepAlive; } inline void setNicehash(bool nicehash) { m_nicehash = nicehash; } - bool isNicehash() const; bool parse(const char *url); bool setUserpass(const char *userpass); + void applyExceptions(); void setPassword(const char *password); void setUser(const char *user);