From 096f136c3678dde4ceeb713aa21018a6b84ea9b1 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 19 Feb 2016 11:29:33 +0100 Subject: [PATCH] enhance vanilla second nonce check --- Algo256/decred.cu | 5 +++-- Algo256/vanilla.cu | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Algo256/decred.cu b/Algo256/decred.cu index 5f5aa4e..5ba4550 100644 --- a/Algo256/decred.cu +++ b/Algo256/decred.cu @@ -391,7 +391,7 @@ extern "C" int scanhash_decred(int thr_id, struct work* work, uint32_t max_nonce rc = 1; work_set_target_ratio(work, vhashcpu); *hashes_done = (*pnonce) - first_nonce + throughput; - work->nonces[0] = *pnonce = swab32(foundNonce); + work->nonces[0] = swab32(foundNonce); #if NBN > 1 if (extra_results[0] != UINT32_MAX) { be32enc(&endiandata[DCR_NONCE_OFT32], extra_results[0]); @@ -400,13 +400,14 @@ extern "C" int scanhash_decred(int thr_id, struct work* work, uint32_t max_nonce work->nonces[1] = swab32(extra_results[0]); if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio) { work_set_target_ratio(work, vhashcpu); - xchg(work->nonces[1], *pnonce); + xchg(work->nonces[1], work->nonces[0]); } rc = 2; } extra_results[0] = UINT32_MAX; } #endif + *pnonce = work->nonces[0]; return rc; } else if (opt_debug) { diff --git a/Algo256/vanilla.cu b/Algo256/vanilla.cu index 6e84be2..1b9cc20 100644 --- a/Algo256/vanilla.cu +++ b/Algo256/vanilla.cu @@ -381,14 +381,20 @@ extern "C" int scanhash_vanilla(int thr_id, struct work* work, uint32_t max_nonc rc = 1; work_set_target_ratio(work, vhashcpu); *hashes_done = pdata[19] - first_nonce + throughput; - pdata[19] = h_resNonce[thr_id][0]; + work->nonces[0] = h_resNonce[thr_id][0]; #if NBN > 1 if (h_resNonce[thr_id][1] != UINT32_MAX) { - pdata[21] = h_resNonce[thr_id][1]; - applog(LOG_BLUE, "1:%x 2:%x", h_resNonce[thr_id][0], h_resNonce[thr_id][1]); + work->nonces[1] = h_resNonce[thr_id][1]; + be32enc(&endiandata[19], work->nonces[1]); + vanillahash(vhashcpu, endiandata, blakerounds); + if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio) { + work_set_target_ratio(work, vhashcpu); + xchg(work->nonces[1], work->nonces[0]); + } rc = 2; } #endif + pdata[19] = work->nonces[0]; return rc; } else {