From d8e18994d52c31024c43d002cac8087ff9bb7c7e Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 1 Dec 2012 23:36:17 +1100 Subject: [PATCH] Support monitoring and reporting much higher diffs for scrypt mining, truncating irrelevant zeroes from displayed hash. --- cgminer.c | 14 ++++++++------ scrypt.c | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cgminer.c b/cgminer.c index 8cbc01eb..018a97fd 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 db3eb092..e569d622 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 */