From 1bd8d6350842c73153758db06023c163eff34f39 Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 10 Apr 2019 03:42:00 +0700 Subject: [PATCH] 64bit diff support. --- src/base/net/stratum/Job.h | 2 +- src/base/net/stratum/SubmitResult.h | 8 ++++---- src/net/JobResult.h | 12 ++++++------ src/net/Network.cpp | 8 ++++---- src/net/NetworkState.cpp | 4 ++-- src/net/NetworkState.h | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/base/net/stratum/Job.h b/src/base/net/stratum/Job.h index 8fc3d7097..c8dced4b7 100644 --- a/src/base/net/stratum/Job.h +++ b/src/base/net/stratum/Job.h @@ -67,7 +67,7 @@ public: inline int threadId() const { return m_threadId; } inline size_t size() const { return m_size; } inline uint32_t *nonce() { return reinterpret_cast(m_blob + 39); } - inline uint32_t diff() const { return static_cast(m_diff); } + inline uint64_t diff() const { return m_diff; } inline uint64_t height() const { return m_height; } inline uint64_t target() const { return m_target; } inline uint8_t fixedByte() const { return *(m_blob + 42); } diff --git a/src/base/net/stratum/SubmitResult.h b/src/base/net/stratum/SubmitResult.h index 583d426fe..5abd3e4bf 100644 --- a/src/base/net/stratum/SubmitResult.h +++ b/src/base/net/stratum/SubmitResult.h @@ -38,17 +38,17 @@ public: inline SubmitResult() : reqId(0), seq(0), - diff(0), actualDiff(0), + diff(0), elapsed(0), m_start(0) {} - inline SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff, int64_t reqId = 0) : + inline SubmitResult(int64_t seq, uint64_t diff, uint64_t actualDiff, int64_t reqId = 0) : reqId(reqId), seq(seq), - diff(diff), actualDiff(actualDiff), + diff(diff), elapsed(0), m_start(Chrono::steadyMSecs()) {} @@ -57,8 +57,8 @@ public: int64_t reqId; int64_t seq; - uint32_t diff; uint64_t actualDiff; + uint64_t diff; uint64_t elapsed; private: diff --git a/src/net/JobResult.h b/src/net/JobResult.h index 9d2300b57..9fe1238e9 100644 --- a/src/net/JobResult.h +++ b/src/net/JobResult.h @@ -41,20 +41,20 @@ namespace xmrig { class JobResult { public: - inline JobResult() : poolId(0), diff(0), nonce(0) {} - inline JobResult(int poolId, const String &jobId, const String &clientId, uint32_t nonce, const uint8_t *result, uint32_t diff, const Algorithm &algorithm) : + inline JobResult() : poolId(0), nonce(0), diff(0) {} + inline JobResult(int poolId, const String &jobId, const String &clientId, uint32_t nonce, const uint8_t *result, uint64_t diff, const Algorithm &algorithm) : algorithm(algorithm), poolId(poolId), clientId(clientId), jobId(jobId), - diff(diff), - nonce(nonce) + nonce(nonce), + diff(diff) { memcpy(this->result, result, sizeof(this->result)); } - inline JobResult(const Job &job) : poolId(0), diff(0), nonce(0) + inline JobResult(const Job &job) : poolId(0), nonce(0), diff(0) { jobId = job.id(); clientId = job.clientId(); @@ -75,8 +75,8 @@ public: int poolId; String clientId; String jobId; - uint32_t diff; uint32_t nonce; + uint64_t diff; uint8_t result[32]; }; diff --git a/src/net/Network.cpp b/src/net/Network.cpp index 5de840ea2..be853cfac 100644 --- a/src/net/Network.cpp +++ b/src/net/Network.cpp @@ -181,11 +181,11 @@ void xmrig::Network::onResultAccepted(IStrategy *, Client *, const SubmitResult m_state.add(result, error); if (error) { - LOG_INFO(RED_BOLD("rejected") " (%" PRId64 "/%" PRId64 ") diff " WHITE_BOLD("%u") " " RED("\"%s\"") " " BLACK_BOLD("(%" PRIu64 " ms)"), + LOG_INFO(RED_BOLD("rejected") " (%" PRId64 "/%" PRId64 ") diff " WHITE_BOLD("%" PRIu64) " " RED("\"%s\"") " " BLACK_BOLD("(%" PRIu64 " ms)"), m_state.accepted, m_state.rejected, result.diff, error, result.elapsed); } else { - LOG_INFO(GREEN_BOLD("accepted") " (%" PRId64 "/%" PRId64 ") diff " WHITE_BOLD("%u") " " BLACK_BOLD("(%" PRIu64 " ms)"), + LOG_INFO(GREEN_BOLD("accepted") " (%" PRId64 "/%" PRId64 ") diff " WHITE_BOLD("%" PRIu64) " " BLACK_BOLD("(%" PRIu64 " ms)"), m_state.accepted, m_state.rejected, result.diff, result.elapsed); } } @@ -194,11 +194,11 @@ void xmrig::Network::onResultAccepted(IStrategy *, Client *, const SubmitResult void xmrig::Network::setJob(Client *client, const Job &job, bool donate) { if (job.height()) { - LOG_INFO(MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s") " height " WHITE_BOLD("%" PRIu64), + LOG_INFO(MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%" PRIu64) " algo " WHITE_BOLD("%s") " height " WHITE_BOLD("%" PRIu64), client->host(), client->port(), job.diff(), job.algorithm().shortName(), job.height()); } else { - LOG_INFO(MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s"), + LOG_INFO(MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%" PRIu64) " algo " WHITE_BOLD("%s"), client->host(), client->port(), job.diff(), job.algorithm().shortName()); } diff --git a/src/net/NetworkState.cpp b/src/net/NetworkState.cpp index df248602a..c55422db7 100644 --- a/src/net/NetworkState.cpp +++ b/src/net/NetworkState.cpp @@ -35,14 +35,14 @@ xmrig::NetworkState::NetworkState() : - diff(0), + pool(), accepted(0), + diff(0), failures(0), rejected(0), total(0), m_active(false) { - memset(pool, 0, sizeof(pool)); } diff --git a/src/net/NetworkState.h b/src/net/NetworkState.h index 2f88d9b30..cf9a649a0 100644 --- a/src/net/NetworkState.h +++ b/src/net/NetworkState.h @@ -50,8 +50,8 @@ public: char pool[256]; std::array topDiff { { } }; - uint32_t diff; uint64_t accepted; + uint64_t diff; uint64_t failures; uint64_t rejected; uint64_t total;