Merge branch 'evo' into feature-per-pool-algo

This commit is contained in:
XMRig 2019-06-26 15:44:52 +07:00
commit 188338c493
19 changed files with 283 additions and 35 deletions

View file

@ -37,6 +37,7 @@
#endif
#include "base/io/json/Json.h"
#include "base/io/json/JsonRequest.h"
#include "base/io/log/Log.h"
#include "base/kernel/interfaces/IClientListener.h"
@ -333,13 +334,8 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
job.setAlgorithm(params["algo"].GetString());
}
if (params.HasMember("height")) {
const rapidjson::Value &variant = params["height"];
if (variant.IsUint64()) {
job.setHeight(variant.GetUint64());
}
}
job.setSeedHash(Json::getString(params, "seed_hash"));
job.setHeight(Json::getUint64(params, "height"));
if (!verifyAlgorithm(job.algorithm())) {
*code = 6;

View file

@ -220,6 +220,7 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value &params, int *code)
return false;
}
job.setSeedHash(Json::getString(params, "seed_hash"));
job.setHeight(Json::getUint64(params, kHeight));
job.setDiff(Json::getUint64(params, "difficulty"));
job.setId(blocktemplate.data() + blocktemplate.size() - 32);

View file

@ -40,7 +40,8 @@ xmrig::Job::Job() :
m_diff(0),
m_height(0),
m_target(0),
m_blob()
m_blob(),
m_seedHash()
{
}
@ -54,7 +55,8 @@ xmrig::Job::Job(int poolId, bool nicehash, const Algorithm &algorithm, const Str
m_diff(0),
m_height(0),
m_target(0),
m_blob()
m_blob(),
m_seedHash()
{
}
@ -103,6 +105,20 @@ bool xmrig::Job::setBlob(const char *blob)
}
bool xmrig::Job::setSeedHash(const char *hash)
{
if (!hash || (strlen(hash) != sizeof(m_seedHash) * 2)) {
return false;
}
# ifdef XMRIG_PROXY_PROJECT
m_rawSeedHash = hash;
# endif
return Buffer::fromHex(hash, sizeof(m_seedHash) * 2, m_seedHash);
}
bool xmrig::Job::setTarget(const char *target)
{
if (!target) {

View file

@ -52,6 +52,7 @@ public:
bool isEqual(const Job &other) const;
bool setBlob(const char *blob);
bool setSeedHash(const char *hash);
bool setTarget(const char *target);
void setDiff(uint64_t diff);
@ -63,6 +64,7 @@ public:
inline const String &id() const { return m_id; }
inline const uint32_t *nonce() const { return reinterpret_cast<const uint32_t*>(m_blob + 39); }
inline const uint8_t *blob() const { return m_blob; }
inline const uint8_t *seedHash() const { return m_seedHash; }
inline int poolId() const { return m_poolId; }
inline size_t size() const { return m_size; }
inline uint32_t *nonce() { return reinterpret_cast<uint32_t*>(m_blob + 39); }
@ -77,9 +79,10 @@ public:
inline void setPoolId(int poolId) { m_poolId = poolId; }
# ifdef XMRIG_PROXY_PROJECT
inline char *rawBlob() { return m_rawBlob; }
inline const char *rawBlob() const { return m_rawBlob; }
inline const char *rawTarget() const { return m_rawTarget; }
inline char *rawBlob() { return m_rawBlob; }
inline const char *rawBlob() const { return m_rawBlob; }
inline const char *rawTarget() const { return m_rawTarget; }
inline const String &rawSeedHash() const { return m_rawSeedHash; }
# endif
static inline uint32_t *nonce(uint8_t *blob) { return reinterpret_cast<uint32_t*>(blob + 39); }
@ -99,10 +102,12 @@ private:
uint64_t m_height;
uint64_t m_target;
uint8_t m_blob[kMaxBlobSize];
uint8_t m_seedHash[32];
# ifdef XMRIG_PROXY_PROJECT
char m_rawBlob[kMaxBlobSize * 2 + 8];
char m_rawTarget[24];
String m_rawSeedHash;
# endif
};