Use an array of offsets when checking nonces in bitfury_checkresults
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index b0b41a1..44e90e0 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -163,23 +163,20 @@ static uint32_t decnonce(uint32_t in)
return out;
}
+#define BT_OFFSETS 3
+const uint32_t bf_offsets[] = {0, -0x400000, -0x800000};
+
static bool bitfury_checkresults(struct thr_info *thr, struct work *work, uint32_t nonce)
{
- uint32_t nonceoff;
-
- if (test_nonce(work, nonce)) {
- submit_nonce(thr, work, nonce);
- return true;
- }
- nonceoff = nonce - 0x400000;
- if (test_nonce(work, nonceoff)) {
- submit_nonce(thr, work, nonceoff);
- return true;
- }
- nonceoff = nonce - 0x800000;
- if (test_nonce(work, nonceoff)) {
- submit_nonce(thr, work, nonceoff);
- return true;
+ uint32_t offset_nonce;
+ int i;
+
+ for (i = 0; i < BT_OFFSETS; i++) {
+ offset_nonce = nonce + bf_offsets[i];
+ if (test_nonce(work, offset_nonce)) {
+ submit_nonce(thr, work, offset_nonce);
+ return true;
+ }
}
return false;
}