Added nicehash extension.

This commit is contained in:
XMRig
2018-03-07 22:10:07 +07:00
parent e5ba679fe2
commit f2c14e9425
3 changed files with 14 additions and 2 deletions

View File

@@ -393,6 +393,11 @@ void Client::parse(char *line, size_t len)
LOG_DEBUG("[%s:%u] received (%d bytes): \"%s\"", m_url.host(), m_url.port(), len, line);
if (len < 32 || line[0] != '{') {
LOG_ERR("[%s:%u] JSON decode failed", m_url.host(), m_url.port());
return;
}
rapidjson::Document doc;
if (doc.ParseInsitu(line).HasParseError()) {
if (!m_quiet) {

View File

@@ -227,6 +227,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;
}

View File

@@ -126,11 +126,13 @@ void Miner::setJob(Job &job)
int size = 0;
if (m_state == WaitReadyState) {
setState(ReadyState);
size = snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"result\":{\"id\":\"%s\",\"job\":{\"blob\":\"%s\",\"job_id\":\"%s%02hhx0\",\"target\":\"%s\"},\"status\":\"OK\"}}\n",
size = snprintf(m_sendBuf, sizeof(m_sendBuf),
"{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"result\":{\"id\":\"%s\",\"job\":{\"blob\":\"%s\",\"job_id\":\"%s%02hhx0\",\"target\":\"%s\"},\"extensions\":[\"nicehash\"],\"status\":\"OK\"}}\n",
m_loginId, m_rpcId, job.rawBlob(), job.id().data(), m_fixedByte, customDiff ? target : job.rawTarget());
}
else {
size = snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"jsonrpc\":\"2.0\",\"method\":\"job\",\"params\":{\"blob\":\"%s\",\"job_id\":\"%s%02hhx0\",\"target\":\"%s\"}}\n",
size = snprintf(m_sendBuf, sizeof(m_sendBuf),
"{\"jsonrpc\":\"2.0\",\"method\":\"job\",\"params\":{\"blob\":\"%s\",\"job_id\":\"%s%02hhx0\",\"target\":\"%s\"}}\n",
job.rawBlob(), job.id().data(), m_fixedByte, customDiff ? target : job.rawTarget());
}