Skip to content

Commit

Permalink
Use 64bit diff throughout
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hyc committed Apr 11, 2019
1 parent 55cb1be commit 0cc72b1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/api/NetworkState.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NetworkState

char pool[256];
std::array<uint64_t, 10> topDiff { { } };
uint32_t diff;
uint64_t diff;
uint64_t accepted;
uint64_t failures;
uint64_t rejected;
Expand Down
2 changes: 1 addition & 1 deletion src/common/net/Job.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t*>(m_blob + 39); }
inline uint32_t diff() const { return static_cast<uint32_t>(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; }
Expand Down
2 changes: 1 addition & 1 deletion src/common/net/SubmitResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/common/net/SubmitResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions src/net/JobResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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];
};

Expand Down
16 changes: 8 additions & 8 deletions src/net/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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());
}

Expand Down

0 comments on commit 0cc72b1

Please sign in to comment.