Sync changes with proxy.

This commit is contained in:
XMRig 2019-06-25 10:35:10 +07:00
parent f7f2c09e89
commit b0a1481909
5 changed files with 30 additions and 36 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"
@ -344,21 +345,8 @@ bool xmrig::Client::parseJob(const rapidjson::Value &params, int *code)
}
}
if (params.HasMember("seed_hash")) {
const rapidjson::Value &variant = params["seed_hash"];
if (variant.IsString()) {
job.setSeedHash(variant.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

@ -221,7 +221,6 @@ bool xmrig::DaemonClient::parseJob(const rapidjson::Value &params, int *code)
}
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

@ -42,8 +42,8 @@ xmrig::Job::Job() :
m_diff(0),
m_height(0),
m_target(0),
m_seedHash(),
m_blob()
m_blob(),
m_seedHash()
{
}
@ -59,8 +59,8 @@ xmrig::Job::Job(int poolId, bool nicehash, const Algorithm &algorithm, const Str
m_diff(0),
m_height(0),
m_target(0),
m_seedHash(),
m_blob()
m_blob(),
m_seedHash()
{
}
@ -113,6 +113,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) {
@ -177,15 +191,6 @@ void xmrig::Job::setDiff(uint64_t diff)
}
bool xmrig::Job::setSeedHash(const char *hash)
{
if (!hash || (strlen(hash) != sizeof(m_seedHash) * 2))
return false;
return Buffer::fromHex(hash, sizeof(m_seedHash) * 2, m_seedHash);
}
xmrig::Variant xmrig::Job::variant() const
{
switch (m_algorithm.algo()) {

View file

@ -52,10 +52,10 @@ public:
bool isEqual(const Job &other) const;
bool setBlob(const char *blob);
bool setSeedHash(const char *hash);
bool setTarget(const char *target);
void setAlgorithm(const char *algo);
void setDiff(uint64_t diff);
bool setSeedHash(const char *hash);
inline bool isNicehash() const { return m_nicehash; }
inline bool isValid() const { return m_size > 0 && m_diff > 0; }
@ -65,7 +65,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 *seed_hash() const { return m_seedHash; }
inline const uint8_t *seedHash() const { return m_seedHash; }
inline int poolId() const { return m_poolId; }
inline int threadId() const { return m_threadId; }
inline size_t size() const { return m_size; }
@ -83,9 +83,10 @@ public:
inline void setVariant(int variant) { m_algorithm.parseVariant(variant); }
# 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); }
@ -108,12 +109,13 @@ private:
uint64_t m_diff;
uint64_t m_height;
uint64_t m_target;
uint8_t m_seedHash[32];
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
};

View file

@ -164,7 +164,7 @@ void MultiWorker<N>::start()
# ifdef XMRIG_ALGO_RANDOMX
if (v == xmrig::VARIANT_RX_WOW) {
allocateRandomX_VM();
Workers::updateDataset(m_state.job.seed_hash(), m_totalWays);
Workers::updateDataset(m_state.job.seedHash(), m_totalWays);
randomx_calculate_hash(m_rx_vm, m_state.blob, m_state.job.size(), m_hash);
}
else