Store the hash2 array in struct work for further reuse.
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
diff --git a/cgminer.c b/cgminer.c
index 5afb3df..77f973f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6010,8 +6010,7 @@ void inc_hw_errors(struct thr_info *thr)
bool test_nonce(struct work *work, uint32_t nonce)
{
uint32_t *work_nonce = (uint32_t *)(work->data + 64 + 12);
- unsigned char hash2[32];
- uint32_t *hash2_32 = (uint32_t *)hash2;
+ uint32_t *hash2_32 = (uint32_t *)work->hash2;
uint32_t diff1targ;
*work_nonce = htole32(nonce);
@@ -6021,15 +6020,13 @@ bool test_nonce(struct work *work, uint32_t nonce)
flip32(hash2_32, work->hash);
diff1targ = opt_scrypt ? 0x0000ffffUL : 0;
- work->hash2_32_7 = be32toh(hash2_32[7]);
- return (work->hash2_32_7 <= diff1targ);
+ return (be32toh(hash2_32[7]) <= diff1targ);
}
/* Returns true if nonce for work was a valid share */
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
{
struct timeval tv_work_found;
- unsigned char hash2[32];
bool ret = true;
cgtime(&tv_work_found);
@@ -6052,7 +6049,7 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
thr->cgpu->last_device_valid_work = time(NULL);
mutex_unlock(&stats_lock);
- if (!fulltest(hash2, work->target)) {
+ if (!fulltest(work->hash2, work->target)) {
applog(LOG_INFO, "Share below target");
goto out;
}
diff --git a/miner.h b/miner.h
index 5bb4038..d8d4148 100644
--- a/miner.h
+++ b/miner.h
@@ -1263,7 +1263,7 @@ struct work {
#endif
double device_diff;
uint64_t share_diff;
- uint32_t hash2_32_7;
+ unsigned char hash2[32];
int rolls;