Fixed NiceHash disconnects for KawPow

This commit is contained in:
SChernykh 2020-06-12 14:08:00 +02:00
parent 945d1db05c
commit 28c81f2c53
3 changed files with 30 additions and 2 deletions

View file

@ -145,6 +145,22 @@ void xmrig::EthStratumClient::parseNotification(const char *method, const rapidj
return;
}
if (strcmp(method, "mining.set_extranonce") == 0) {
if (!params.IsArray()) {
LOG_ERR("%s " RED("invalid mining.set_extranonce notification: params is not an array"), tag());
return;
}
auto arr = params.GetArray();
if (arr.Empty()) {
LOG_ERR("%s " RED("invalid mining.set_extranonce notification: params array is empty"), tag());
return;
}
setExtraNonce(arr[0]);
}
if (strcmp(method, "mining.notify") == 0) {
if (!params.IsArray()) {
LOG_ERR("%s " RED("invalid mining.notify notification: params is not an array"), tag());
@ -345,6 +361,14 @@ void xmrig::EthStratumClient::onSubscribeResponse(const rapidjson::Value &result
}
setExtraNonce(result.GetArray()[1]);
if (m_pool.isNicehash()) {
using namespace rapidjson;
Document doc(kObjectType);
Value params(kArrayType);
JsonRequest::create(doc, m_sequence, "mining.extranonce.subscribe", params);
send(doc);
}
} catch (const std::exception &ex) {
LOG_ERR("%s " RED("%s"), tag(), ex.what());

View file

@ -74,6 +74,9 @@ const char *Pool::kUrl = "url";
const char *Pool::kUser = "user";
const char *Pool::kNicehashHost = "nicehash.com";
}
@ -94,7 +97,7 @@ xmrig::Pool::Pool(const char *host, uint16_t port, const char *user, const char
m_pollInterval(kDefaultPollInterval),
m_url(host, port, tls)
{
m_flags.set(FLAG_NICEHASH, nicehash);
m_flags.set(FLAG_NICEHASH, nicehash || strstr(host, kNicehashHost));
m_flags.set(FLAG_TLS, tls);
}
@ -119,7 +122,7 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
m_proxy = Json::getValue(object, kSOCKS5);
m_flags.set(FLAG_ENABLED, Json::getBool(object, kEnabled, true));
m_flags.set(FLAG_NICEHASH, Json::getBool(object, kNicehash));
m_flags.set(FLAG_NICEHASH, Json::getBool(object, kNicehash) || m_url.host().contains(kNicehashHost));
m_flags.set(FLAG_TLS, Json::getBool(object, kTls) || m_url.isTLS());
if (m_daemon.isValid()) {

View file

@ -71,6 +71,7 @@ public:
static const char *kTls;
static const char *kUrl;
static const char *kUser;
static const char *kNicehashHost;
constexpr static int kKeepAliveTimeout = 60;
constexpr static uint16_t kDefaultPort = 3333;