Support monitoring and reporting much higher diffs for scrypt mining, truncating irrelevant zeroes from displayed hash.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
diff --git a/cgminer.c b/cgminer.c
index 8cbc01e..018a97f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2264,12 +2264,12 @@ static uint64_t share_diff(const struct work *work)
static uint32_t scrypt_diff(const struct work *work)
{
- const uint32_t scrypt_diffone = 0x0000fffful;
- uint32_t d32 = work->outputhash, ret;
+ const uint64_t scrypt_diffone = 0x0000ffff00000000ul;
+ uint64_t d64 = work->outputhash, ret;
- if (unlikely(!d32))
- d32 = 1;
- ret = scrypt_diffone / d32;
+ if (unlikely(!d64))
+ d64 = 1;
+ ret = scrypt_diffone / d64;
if (ret > best_diff) {
best_diff = ret;
suffix_string(best_diff, best_share, 0);
@@ -2367,12 +2367,14 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
hash32 = (uint32_t *)(work->hash);
if (opt_scrypt) {
uint32_t sharediff;
+ uint64_t outhash;
scrypt_outputhash(work);
sharediff = scrypt_diff(work);
suffix_string(sharediff, diffdisp, 0);
- sprintf(hashshow, "%08lx Diff %s/%d", (unsigned long)work->outputhash, diffdisp, intdiff);
+ outhash = work->outputhash >> 16;
+ sprintf(hashshow, "%08lx Diff %s/%d", (unsigned long)outhash, diffdisp, intdiff);
} else {
uint64_t sharediff = share_diff(work);
diff --git a/scrypt.c b/scrypt.c
index db3eb09..e569d62 100644
--- a/scrypt.c
+++ b/scrypt.c
@@ -404,7 +404,7 @@ static void scrypt_1024_1_1_256_sp(const uint32_t* input, char* scratchpad, uint
void scrypt_outputhash(struct work *work)
{
- uint32_t data[20], ohash[8];
+ uint32_t data[20], ohash[8], rhash[8];
char *scratchbuf;
uint32_t *nonce = (uint32_t *)(work->data + 76);
@@ -412,7 +412,8 @@ void scrypt_outputhash(struct work *work)
data[19] = htobe32(*nonce);
scratchbuf = alloca(131584);
scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
- work->outputhash = be32toh(ohash[7]);
+ swap256(rhash, ohash);
+ work->outputhash = be64toh(*((uint64_t *)rhash));
}
/* Used externally as confirmation of correct OCL code */