From 0cc72b18c4daf4b3349cb276310510a4263a84a6 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 5 Apr 2019 21:30:03 +0100 Subject: [PATCH] Use 64bit diff throughout This appears to be mainly cosmetic. Difficulty values from the daemon are larger than 32bits, and the value being displayed was being truncated. Doesn't appear to affect mining, which uses the 64bit target. --- src/api/NetworkState.h | 2 +- src/common/net/Job.h | 2 +- src/common/net/SubmitResult.cpp | 2 +- src/common/net/SubmitResult.h | 4 ++-- src/net/JobResult.h | 12 ++++++------ src/net/Network.cpp | 16 ++++++++-------- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/api/NetworkState.h b/src/api/NetworkState.h index c45761fb..f777f984 100644 --- a/src/api/NetworkState.h +++ b/src/api/NetworkState.h @@ -50,7 +50,7 @@ class NetworkState char pool[256]; std::array topDiff { { } }; - uint32_t diff; + uint64_t diff; uint64_t accepted; uint64_t failures; uint64_t rejected; diff --git a/src/common/net/Job.h b/src/common/net/Job.h index 4fac59c9..9089e71c 100644 --- a/src/common/net/Job.h +++ b/src/common/net/Job.h @@ -72,7 +72,7 @@ class Job 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 target() const { return m_target; } inline uint64_t height() const { return m_height; } inline void reset() { m_size = 0; m_diff = 0; } diff --git a/src/common/net/SubmitResult.cpp b/src/common/net/SubmitResult.cpp index d14bbb40..7171cd7e 100644 --- a/src/common/net/SubmitResult.cpp +++ b/src/common/net/SubmitResult.cpp @@ -29,7 +29,7 @@ #include "common/net/SubmitResult.h" -xmrig::SubmitResult::SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff, int64_t reqId) : +xmrig::SubmitResult::SubmitResult(int64_t seq, uint64_t diff, uint64_t actualDiff, int64_t reqId) : reqId(reqId), seq(seq), diff(diff), diff --git a/src/common/net/SubmitResult.h b/src/common/net/SubmitResult.h index db97ac38..a992d302 100644 --- a/src/common/net/SubmitResult.h +++ b/src/common/net/SubmitResult.h @@ -36,13 +36,13 @@ class SubmitResult { public: inline SubmitResult() : reqId(0), seq(0), diff(0), actualDiff(0), elapsed(0), start(0) {} - SubmitResult(int64_t seq, uint32_t diff, uint64_t actualDiff, int64_t reqId = 0); + SubmitResult(int64_t seq, uint64_t diff, uint64_t actualDiff, int64_t reqId = 0); void done(); int64_t reqId; int64_t seq; - uint32_t diff; + uint64_t diff; uint64_t actualDiff; uint64_t elapsed; diff --git a/src/net/JobResult.h b/src/net/JobResult.h index 5ab4d294..b2d16c2a 100644 --- a/src/net/JobResult.h +++ b/src/net/JobResult.h @@ -40,20 +40,20 @@ namespace xmrig { class JobResult { public: - inline JobResult() : poolId(0), diff(0), nonce(0) {} - inline JobResult(int poolId, const Id &jobId, const Id &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 Id &jobId, const Id &clientId, uint32_t nonce, const uint8_t *result, uint64_t diff, const Algorithm &algorithm) : algorithm(algorithm), clientId(clientId), jobId(jobId), poolId(poolId), - 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(); @@ -74,8 +74,8 @@ class JobResult Id clientId; Id jobId; int poolId; - 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 9a1e190b..f3f7affb 100644 --- a/src/net/Network.cpp +++ b/src/net/Network.cpp @@ -163,13 +163,13 @@ void xmrig::Network::onResultAccepted(IStrategy *, Client *, const SubmitResult m_state.add(result, error); if (error) { - LOG_INFO(isColors() ? "\x1B[1;31mrejected\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[1;37m%u\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[1;30m(%" PRIu64 " ms)" - : "rejected (%" PRId64 "/%" PRId64 ") diff %u \"%s\" (%" PRIu64 " ms)", + LOG_INFO(isColors() ? "\x1B[1;31mrejected\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[1;37m%" PRIu64 "\x1B[0m \x1B[31m\"%s\"\x1B[0m \x1B[1;30m(%" PRIu64 " ms)" + : "rejected (%" PRId64 "/%" PRId64 ") diff %" PRIu64 " \"%s\" (%" PRIu64 " ms)", m_state.accepted, m_state.rejected, result.diff, error, result.elapsed); } else { - LOG_INFO(isColors() ? "\x1B[1;32maccepted\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[1;37m%u\x1B[0m \x1B[1;30m(%" PRIu64 " ms)" - : "accepted (%" PRId64 "/%" PRId64 ") diff %u (%" PRIu64 " ms)", + LOG_INFO(isColors() ? "\x1B[1;32maccepted\x1B[0m (%" PRId64 "/%" PRId64 ") diff \x1B[1;37m%" PRIu64 "\x1B[0m \x1B[1;30m(%" PRIu64 " ms)" + : "accepted (%" PRId64 "/%" PRId64 ") diff %" PRIu64 " (%" PRIu64 " ms)", m_state.accepted, m_state.rejected, result.diff, result.elapsed); } } @@ -184,13 +184,13 @@ bool xmrig::Network::isColors() const void xmrig::Network::setJob(Client *client, const Job &job, bool donate) { if (job.height()) { - LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s") " height " WHITE_BOLD("%" PRIu64) - : "new job from %s:%d diff %d algo %s height %" PRIu64, + LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%" PRIu64) " algo " WHITE_BOLD("%s") " height " WHITE_BOLD("%" PRIu64) + : "new job from %s:%d diff %" PRIu64 " algo %s height %" PRIu64, client->host(), client->port(), job.diff(), job.algorithm().shortName(), job.height()); } else { - LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%d") " algo " WHITE_BOLD("%s") - : "new job from %s:%d diff %d algo %s", + LOG_INFO(isColors() ? MAGENTA_BOLD("new job") " from " WHITE_BOLD("%s:%d") " diff " WHITE_BOLD("%" PRIu64) " algo " WHITE_BOLD("%s") + : "new job from %s:%d diff %" PRIu64 " algo %s", client->host(), client->port(), job.diff(), job.algorithm().shortName()); }