mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-22 11:39:33 +00:00
Sync changes with the proxy.
This commit is contained in:
parent
98c775703e
commit
3dfeed475f
3 changed files with 33 additions and 32 deletions
|
@ -363,7 +363,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
|
||||
Job job(has<EXT_NICEHASH>(), m_pool.algorithm(), m_rpcId);
|
||||
|
||||
if (!job.setId(params["job_id"].GetString())) {
|
||||
if (!job.setId(Json::getString(params, "job_id"))) {
|
||||
*code = 3;
|
||||
return false;
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||
}
|
||||
}
|
||||
|
||||
if (!job.setTarget(params["target"].GetString())) {
|
||||
if (!job.setTarget(Json::getString(params, "target"))) {
|
||||
*code = 5;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -110,16 +110,12 @@ bool xmrig::Job::setSeedHash(const char *hash)
|
|||
|
||||
bool xmrig::Job::setTarget(const char *target)
|
||||
{
|
||||
static auto parse = [](const char *target, const Algorithm &algorithm) -> uint64_t {
|
||||
if (!target) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static auto parse = [](const char *target, size_t size, const Algorithm &algorithm) -> uint64_t {
|
||||
if (algorithm == Algorithm::RX_YADA) {
|
||||
return strtoull(target, nullptr, 16);
|
||||
}
|
||||
|
||||
const auto raw = Cvt::fromHex(target, strlen(target));
|
||||
const auto raw = Cvt::fromHex(target, size);
|
||||
|
||||
switch (raw.size()) {
|
||||
case 4:
|
||||
|
@ -135,23 +131,48 @@ bool xmrig::Job::setTarget(const char *target)
|
|||
return 0;
|
||||
};
|
||||
|
||||
if ((m_target = parse(target, algorithm())) == 0) {
|
||||
const size_t size = target ? strlen(target) : 0;
|
||||
|
||||
if (size < 4 || (m_target = parse(target, size, algorithm())) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_diff = toDiff(m_target);
|
||||
|
||||
# ifdef XMRIG_PROXY_PROJECT
|
||||
assert(sizeof(m_rawTarget) > (size * 2));
|
||||
if (size >= sizeof(m_rawTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(m_rawTarget, 0, sizeof(m_rawTarget));
|
||||
memcpy(m_rawTarget, target, std::min(size * 2, sizeof(m_rawTarget)));
|
||||
memcpy(m_rawTarget, target, size);
|
||||
# endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::Job::nonceOffset() const
|
||||
{
|
||||
switch (algorithm().family()) {
|
||||
case Algorithm::KAWPOW:
|
||||
return 32;
|
||||
|
||||
case Algorithm::GHOSTRIDER:
|
||||
return 76;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (algorithm() == Algorithm::RX_YADA) {
|
||||
return 147;
|
||||
}
|
||||
|
||||
return 39;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Job::setDiff(uint64_t diff)
|
||||
{
|
||||
m_diff = diff;
|
||||
|
@ -182,26 +203,6 @@ void xmrig::Job::setSigKey(const char *sig_key)
|
|||
}
|
||||
|
||||
|
||||
int32_t xmrig::Job::nonceOffset() const
|
||||
{
|
||||
switch (algorithm().family()) {
|
||||
case Algorithm::KAWPOW:
|
||||
return 32;
|
||||
|
||||
case Algorithm::GHOSTRIDER:
|
||||
return 76;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (algorithm() == Algorithm::RX_YADA) {
|
||||
return 147;
|
||||
}
|
||||
|
||||
return 39;
|
||||
}
|
||||
|
||||
uint32_t xmrig::Job::getNumTransactions() const
|
||||
{
|
||||
if (!(m_algorithm.isCN() || m_algorithm.family() == Algorithm::RANDOM_X)) {
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
bool setBlob(const char *blob);
|
||||
bool setSeedHash(const char *hash);
|
||||
bool setTarget(const char *target);
|
||||
size_t nonceOffset() const;
|
||||
void setDiff(uint64_t diff);
|
||||
void setSigKey(const char *sig_key);
|
||||
|
||||
|
@ -75,7 +76,6 @@ public:
|
|||
inline const String &poolWallet() const { return m_poolWallet; }
|
||||
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + nonceOffset()); }
|
||||
inline const uint8_t *blob() const { return m_blob; }
|
||||
int32_t nonceOffset() const;
|
||||
inline size_t nonceSize() const { return (algorithm().family() == Algorithm::KAWPOW) ? 8 : 4; }
|
||||
inline size_t size() const { return m_size; }
|
||||
inline uint32_t *nonce() { return reinterpret_cast<uint32_t*>(m_blob + nonceOffset()); }
|
||||
|
|
Loading…
Reference in a new issue