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
|
/CMakeLists.txt.user
|
||||||
/.idea
|
/.idea
|
||||||
/src/backend/opencl/cl/cn/cryptonight_gen.cl
|
/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 *kNextSeedHash = "next_seed_hash";
|
||||||
static const char *kPrevHash = "prev_hash";
|
static const char *kPrevHash = "prev_hash";
|
||||||
static const char *kSeedHash = "seed_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 };
|
static const char * const required_fields[] = { kBlocktemplateBlob, kBlockhashingBlob, kHeight, kDifficulty, kPrevHash };
|
||||||
|
|
||||||
|
@ -57,6 +59,7 @@ xmrig::SelfSelectClient::SelfSelectClient(int id, const char *agent, IClientList
|
||||||
{
|
{
|
||||||
m_httpListener = std::make_shared<HttpListener>(this);
|
m_httpListener = std::make_shared<HttpListener>(this);
|
||||||
m_client = new Client(id, agent, 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;
|
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) {
|
for (auto field : required_fields) {
|
||||||
if (!result.HasMember(field)) {
|
if (!result.HasMember(field)) {
|
||||||
LOG_ERR("[%s] required field " RED_BOLD("\"%s\"") RED_S " not found", pool().daemon().url().data(), 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;
|
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()
|
void xmrig::SelfSelectClient::getBlockTemplate()
|
||||||
{
|
{
|
||||||
|
@ -282,8 +303,8 @@ void xmrig::SelfSelectClient::submitOriginDaemon(const JobResult& result)
|
||||||
Value params(kArrayType);
|
Value params(kArrayType);
|
||||||
params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator());
|
params.PushBack(m_blocktemplate.toJSON(), doc.GetAllocator());
|
||||||
|
|
||||||
JsonRequest::create(doc, m_sequence, "submitblock", params);
|
m_last_submit_req_id = m_sequence;
|
||||||
m_results[m_sequence] = SubmitResult(m_sequence, result.diff, result.actualDiff(), 0, result.backend);
|
JsonRequest::create(doc, m_sequence++, "submitblock", params);
|
||||||
|
|
||||||
FetchRequest req(HTTP_POST, pool().daemon().host(), pool().daemon().port(), "/json_rpc", doc, pool().daemon().isTLS(), isQuiet());
|
FetchRequest req(HTTP_POST, pool().daemon().host(), pool().daemon().port(), "/json_rpc", doc, pool().daemon().isTLS(), isQuiet());
|
||||||
fetch(tag(), std::move(req), m_httpListener);
|
fetch(tag(), std::move(req), m_httpListener);
|
||||||
|
|
|
@ -99,6 +99,7 @@ private:
|
||||||
void getBlockTemplate();
|
void getBlockTemplate();
|
||||||
void retry();
|
void retry();
|
||||||
void setState(State state);
|
void setState(State state);
|
||||||
|
bool isSubmitBlockResponse(int64_t id);
|
||||||
void submitBlockTemplate(rapidjson::Value &result);
|
void submitBlockTemplate(rapidjson::Value &result);
|
||||||
void submitOriginDaemon(const JobResult &result);
|
void submitOriginDaemon(const JobResult &result);
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ private:
|
||||||
int64_t m_sequence = 1;
|
int64_t m_sequence = 1;
|
||||||
Job m_job;
|
Job m_job;
|
||||||
State m_state = IdleState;
|
State m_state = IdleState;
|
||||||
std::map<int64_t, SubmitResult> m_results;
|
int64_t m_last_submit_req_id;
|
||||||
std::shared_ptr<IHttpListener> m_httpListener;
|
std::shared_ptr<IHttpListener> m_httpListener;
|
||||||
String m_blocktemplate;
|
String m_blocktemplate;
|
||||||
uint64_t m_blockDiff = 0;
|
uint64_t m_blockDiff = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue