Updated version
This commit is contained in:
commit
37e37d3a63
88 changed files with 7771 additions and 1084 deletions
|
@ -56,6 +56,8 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc)
|
|||
|
||||
rapidjson::OStreamWrapper osw(ofs);
|
||||
rapidjson::PrettyWriter<rapidjson::OStreamWrapper> writer(osw);
|
||||
writer.SetFormatOptions(rapidjson::kFormatSingleLineArray);
|
||||
|
||||
doc.Accept(writer);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -118,6 +118,8 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc)
|
|||
|
||||
OStreamWrapper osw(ofs);
|
||||
PrettyWriter<OStreamWrapper> writer(osw);
|
||||
writer.SetFormatOptions(kFormatSingleLineArray);
|
||||
|
||||
doc.Accept(writer);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -57,6 +57,14 @@
|
|||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static const char *kConfigPathV1 = "/1/config";
|
||||
static const char *kConfigPathV2 = "/2/config";
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
class xmrig::BasePrivate
|
||||
{
|
||||
public:
|
||||
|
@ -296,7 +304,7 @@ void xmrig::Base::onFileChanged(const String &fileName)
|
|||
void xmrig::Base::onRequest(IApiRequest &request)
|
||||
{
|
||||
if (request.method() == IApiRequest::METHOD_GET) {
|
||||
if (request.url() == "/1/config") {
|
||||
if (request.url() == kConfigPathV1 || request.url() == kConfigPathV2) {
|
||||
if (request.isRestricted()) {
|
||||
return request.done(403);
|
||||
}
|
||||
|
@ -306,7 +314,7 @@ void xmrig::Base::onRequest(IApiRequest &request)
|
|||
}
|
||||
}
|
||||
else if (request.method() == IApiRequest::METHOD_PUT || request.method() == IApiRequest::METHOD_POST) {
|
||||
if (request.url() == "/1/config") {
|
||||
if (request.url() == kConfigPathV1 || request.url() == kConfigPathV2) {
|
||||
request.accept();
|
||||
|
||||
if (!reload(request.json())) {
|
||||
|
|
|
@ -80,6 +80,8 @@ void xmrig::HttpApiResponse::end()
|
|||
StringBuffer buffer(nullptr, 4096);
|
||||
PrettyWriter<StringBuffer> writer(buffer);
|
||||
writer.SetMaxDecimalPlaces(10);
|
||||
writer.SetFormatOptions(kFormatSingleLineArray);
|
||||
|
||||
m_doc.Accept(writer);
|
||||
|
||||
HttpResponse::end(buffer.GetString(), buffer.GetSize());
|
||||
|
|
|
@ -335,13 +335,19 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
job.setAlgorithm(algo);
|
||||
}
|
||||
|
||||
job.setSeedHash(Json::getString(params, "seed_hash"));
|
||||
job.setHeight(Json::getUint64(params, "height"));
|
||||
|
||||
if (!verifyAlgorithm(job.algorithm(), algo)) {
|
||||
*code = 6;
|
||||
return false;
|
||||
}
|
||||
|
||||
close();
|
||||
if (job.algorithm().family() == Algorithm::RANDOM_X && !job.setSeedHash(Json::getString(params, "seed_hash"))) {
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("[%s] failed to parse field \"seed_hash\" required by RandomX", url(), algo);
|
||||
}
|
||||
|
||||
*code = 7;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -693,6 +699,9 @@ void xmrig::Client::parseNotification(const char *method, const rapidjson::Value
|
|||
if (parseJob(params, &code)) {
|
||||
m_listener->onJobReceived(this, m_job, params);
|
||||
}
|
||||
else {
|
||||
close();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -174,6 +174,13 @@ void xmrig::Job::copy(const Job &other)
|
|||
m_target = other.m_target;
|
||||
m_index = other.m_index;
|
||||
|
||||
memcpy(m_blob, other.m_blob, sizeof (m_blob));
|
||||
memcpy(m_blob, other.m_blob, sizeof(m_blob));
|
||||
memcpy(m_seedHash, other.m_seedHash, sizeof(m_seedHash));
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
m_rawSeedHash = other.m_rawSeedHash;
|
||||
|
||||
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
||||
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
||||
# endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue