mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-22 19:49:36 +00:00
Merge pull request #3232 from moneromooo-monero/xhd-dev
DaemonClient: new X-Hash-Difficulty HTTP header optimization
This commit is contained in:
commit
e352109431
2 changed files with 7 additions and 3 deletions
|
@ -178,7 +178,9 @@ int64_t xmrig::DaemonClient::submit(const JobResult &result)
|
|||
m_results[m_sequence] = SubmitResult(m_sequence, result.diff, result.actualDiff(), 0, result.backend);
|
||||
# endif
|
||||
|
||||
return rpcSend(doc);
|
||||
std::map<std::string, std::string> headers;
|
||||
headers.insert({"X-Hash-Difficulty", std::to_string(result.actualDiff())});
|
||||
return rpcSend(doc, headers);
|
||||
}
|
||||
|
||||
|
||||
|
@ -553,9 +555,11 @@ int64_t xmrig::DaemonClient::getBlockTemplate()
|
|||
}
|
||||
|
||||
|
||||
int64_t xmrig::DaemonClient::rpcSend(const rapidjson::Document &doc)
|
||||
int64_t xmrig::DaemonClient::rpcSend(const rapidjson::Document &doc, const std::map<std::string, std::string> &headers)
|
||||
{
|
||||
FetchRequest req(HTTP_POST, m_pool.host(), m_pool.port(), kJsonRPC, doc, m_pool.isTLS(), isQuiet());
|
||||
for (const auto &header: headers)
|
||||
req.headers.insert(header);
|
||||
fetch(tag(), std::move(req), m_httpListener);
|
||||
|
||||
return m_sequence++;
|
||||
|
|
|
@ -86,7 +86,7 @@ private:
|
|||
bool parseJob(const rapidjson::Value ¶ms, int *code);
|
||||
bool parseResponse(int64_t id, const rapidjson::Value &result, const rapidjson::Value &error);
|
||||
int64_t getBlockTemplate();
|
||||
int64_t rpcSend(const rapidjson::Document &doc);
|
||||
int64_t rpcSend(const rapidjson::Document &doc, const std::map<std::string, std::string> &headers = {});
|
||||
void retry();
|
||||
void send(const char *path);
|
||||
void setState(SocketState state);
|
||||
|
|
Loading…
Reference in a new issue