mirror of
https://github.com/xmrig/xmrig.git
synced 2025-04-10 00:17:29 +00:00
Merge af18c4571e
into f9e990d0f0
This commit is contained in:
commit
f11be94e63
3 changed files with 34 additions and 6 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -4,3 +4,9 @@ scripts/deps
|
|||
/CMakeLists.txt.user
|
||||
/.idea
|
||||
/src/backend/opencl/cl/cn/cryptonight_gen.cl
|
||||
*.a
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
/xmrig
|
|
@ -45,6 +45,8 @@ static const char *kJobId = "job_id";
|
|||
static const char *kNextSeedHash = "next_seed_hash";
|
||||
static const char *kPrevHash = "prev_hash";
|
||||
static const char *kSeedHash = "seed_hash";
|
||||
static const char *kStatus = "status";
|
||||
static const char *kStatusOk = "OK";
|
||||
|
||||
static const char * const required_fields[] = { kBlocktemplateBlob, kBlockhashingBlob, kHeight, kDifficulty, kPrevHash };
|
||||
|
||||
|
@ -55,8 +57,9 @@ xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientList
|
|||
m_submitToOrigin(submitToOrigin),
|
||||
m_listener(listener)
|
||||
{
|
||||
m_httpListener = std::make_shared<HttpListener>(this);
|
||||
m_client = new Client(id, agent, this);
|
||||
m_httpListener = std::make_shared<HttpListener>(this);
|
||||
m_client = new Client(id, agent, this);
|
||||
m_last_submit_req_id = -1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,6 +132,20 @@ bool xmrig::SelfSelectClient::parseResponse(int64_t id, rapidjson::Value &result
|
|||
return false;
|
||||
}
|
||||
|
||||
if (isSubmitBlockResponse(id)) {
|
||||
xmrig::String submit_status = Json::getString(result, kStatus);
|
||||
submit_status.toUpper();
|
||||
if (submit_status == kStatusOk) {
|
||||
// Ensure that the latest block template is available after block submission
|
||||
getBlockTemplate();
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_ERR("[%s] " RED_BOLD("block not submitted to origin. status = \"%s\""), pool().daemon().url().data(), submit_status.data());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (auto field : required_fields) {
|
||||
if (!result.HasMember(field)) {
|
||||
LOG_ERR("[%s] required field " RED_BOLD("\"%s\"") RED_S " not found", pool().daemon().url().data(), field);
|
||||
|
@ -158,6 +175,10 @@ bool xmrig::SelfSelectClient::parseResponse(int64_t id, rapidjson::Value &result
|
|||
return true;
|
||||
}
|
||||
|
||||
bool xmrig::SelfSelectClient::isSubmitBlockResponse(int64_t id)
|
||||
{
|
||||
return m_last_submit_req_id > -1 && id == m_last_submit_req_id;
|
||||
}
|
||||
|
||||
void xmrig::SelfSelectClient::getBlockTemplate()
|
||||
{
|
||||
|
@ -282,8 +303,8 @@ void xmrig::SelfSelectClient::submitOriginDaemon(const JobResult& result)
|
|||
Value params(kArrayType);
|
||||
params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator());
|
||||
|
||||
JsonRequest::create(doc, m_sequence, "submitblock", params);
|
||||
m_results[m_sequence] = SubmitResult(m_sequence, result.diff, result.actualDiff(), 0, result.backend);
|
||||
m_last_submit_req_id = m_sequence;
|
||||
JsonRequest::create(doc, m_sequence++, "submitblock", params);
|
||||
|
||||
FetchRequest req(HTTP_POST, pool().daemon().host(), pool().daemon().port(), "/json_rpc", doc, pool().daemon().isTLS(), isQuiet());
|
||||
fetch(tag(), std::move(req), m_httpListener);
|
||||
|
|
|
@ -99,6 +99,7 @@ private:
|
|||
void getBlockTemplate();
|
||||
void retry();
|
||||
void setState(State state);
|
||||
bool isSubmitBlockResponse(int64_t id);
|
||||
void submitBlockTemplate(rapidjson::Value &result);
|
||||
void submitOriginDaemon(const JobResult &result);
|
||||
|
||||
|
@ -112,8 +113,8 @@ private:
|
|||
int64_t m_sequence = 1;
|
||||
Job m_job;
|
||||
State m_state = IdleState;
|
||||
std::map<int64_t, SubmitResult> m_results;
|
||||
std::shared_ptr<IHttpListener> m_httpListener;
|
||||
int64_t m_last_submit_req_id;
|
||||
std::shared_ptr<IHttpListener> m_httpListener;
|
||||
String m_blocktemplate;
|
||||
uint64_t m_blockDiff = 0;
|
||||
uint64_t m_originNotSubmitted = 0;
|
||||
|
|
Loading…
Reference in a new issue