Commit 54e218b6d4aaa0d4abd7e063f1f0281175f7f168

Con Kolivas 2012-12-24T11:19:33

Simplify the setting of the nonce data field in work on submitting nonces.

diff --git a/cgminer.c b/cgminer.c
index 10a5095..a301a5f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -5168,27 +5168,13 @@ static bool hashtest(struct thr_info *thr, struct work *work)
 	return test;
 }
 
-static bool test_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
-{
-	if (opt_scrypt) {
-		uint32_t *work_nonce = (uint32_t *)(work->data + 64 + 12);
-
-		*work_nonce = nonce;
-		return true;
-	}
-
-	work->data[64 + 12 + 0] = (nonce >> 0) & 0xff;
-	work->data[64 + 12 + 1] = (nonce >> 8) & 0xff;
-	work->data[64 + 12 + 2] = (nonce >> 16) & 0xff;
-	work->data[64 + 12 + 3] = (nonce >> 24) & 0xff;
-
-	return hashtest(thr, work);
-}
-
 void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 {
+	uint32_t *work_nonce = (uint32_t *)(work->data + 64 + 12);
 	struct timeval tv_work_found;
+
 	gettimeofday(&tv_work_found, NULL);
+	*work_nonce = htole32(nonce);
 
 	mutex_lock(&stats_lock);
 	total_diff1++;
@@ -5197,8 +5183,7 @@ void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
 	mutex_unlock(&stats_lock);
 
 	/* Do one last check before attempting to submit the work */
-	/* Side effect: sets work->data for us */
-	if (!test_nonce(thr, work, nonce))
+	if (!opt_scrypt && !hashtest(thr, work))
 		return;
 
 	submit_work_async(work, &tv_work_found);