Use bitfury_checkresults to avoid hashing results twice in nanofury.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 7305f70..b98c641 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -427,6 +427,8 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
bitfury->drv->name, bitfury->device_id, bitfury->device_path);
spi_clear_buf(info);
}
+
+ info->total_nonces = 1;
out:
if (!ret)
nf1_close(bitfury);
@@ -918,18 +920,8 @@ static int64_t nf1_scan(struct thr_info *thr, struct cgpu_info *bitfury,
return -1;
if (info->job_switched) {
- int i, j;
- unsigned int *res = info->results;
- struct work *owork = info->owork;
-
- i = info->results_n;
- for (j = i - 1; j >= 0; j--) {
- if (owork)
- submit_nonce(thr, owork, res[j]);
- }
info->owork = info->work;
info->work = NULL;
- ret += 0xffffffffull * i;
}
aged = age_queued_work(bitfury, 6.0);
@@ -937,6 +929,15 @@ static int64_t nf1_scan(struct thr_info *thr, struct cgpu_info *bitfury,
applog(LOG_DEBUG, "%s %d: Aged %d work items", bitfury->drv->name,
bitfury->device_id, aged);
}
+
+ ret = bitfury_rate(info);
+
+ if (unlikely(bitfury->usbinfo.nodev)) {
+ applog(LOG_WARNING, "%s %d: Device disappeared, disabling thread",
+ bitfury->drv->name, bitfury->device_id);
+ ret = -1;
+ }
+
return ret;
}
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 9afb5b3..4837764 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -30,7 +30,7 @@ extern int opt_bxf_temp_target;
#define NF1_PIN_PWR_EN 6
#define SPIBUF_SIZE 16384
-#define BITFURY_REFRESH_DELAY 100
+#define BITFURY_REFRESH_DELAY 1200
#define BITFURY_DETECT_TRIES 3000 / BITFURY_REFRESH_DELAY
struct bitfury_payload {
diff --git a/libbitfury.c b/libbitfury.c
index 97e784d..9c16b0d 100644
--- a/libbitfury.c
+++ b/libbitfury.c
@@ -83,23 +83,6 @@ static unsigned int atrvec[] = {
};
static bool atrvec_set;
-static bool rehash(unsigned int *mid32, unsigned char *in)
-{
- unsigned out32[8];
- unsigned char *out = (unsigned char *) out32;
- sha256_ctx ctx;
-
- memset(&ctx, 0, sizeof( sha256_ctx ));
- memcpy(ctx.h, mid32, 8 * 4);
- ctx.tot_len = 64;
-
- sha256_update(&ctx, in, 16);
- sha256_final(&ctx, out);
- sha256(out, 32, out);
-
- return (out32[7] == 0);
-}
-
void bitfury_work_to_payload(struct bitfury_payload *p, struct work *work)
{
memcpy(p->midstate, work->midstate, 32);
@@ -360,46 +343,16 @@ bool libbitfury_sendHashData(struct thr_info *thr, struct cgpu_info *bitfury,
if (second_run && info->job_switched) {
int i;
- int results_num = 0;
- unsigned int *results = info->results;
for (i = 0; i < 16; i++) {
- if (oldbuf[i] != newbuf[i]) {
- unsigned char in[16];
- unsigned int *in32 = (unsigned int *)in;
- unsigned int *mid32;
- uint32_t nonce, pn; //possible nonce
- bool found = false;
-
- mid32 = (unsigned int *)op->midstate;
- pn = decnonce(newbuf[i]);
- in32[0] = bswap_32(op->m7);
- in32[1] = bswap_32(op->ntime);
- in32[2] = bswap_32(op->nbits);
-
- nonce = pn - 0x800000;
- in32[3] = bswap_32(nonce);
- if (rehash(mid32, in)) {
- found = true;
- goto out_found;
- }
- nonce = pn;
- in32[3] = bswap_32(nonce);
- if (rehash(mid32, in)) {
- found = true;
- goto out_found;
-
- }
- nonce = pn - 0x400000;
- in32[3] = bswap_32(nonce);
- if (rehash(mid32, in))
- found = true;
-out_found:
- if (found)
- results[results_num++] = nonce;
+ if (oldbuf[i] != newbuf[i] && info->owork) {
+ uint32_t nonce; //possible nonce
+
+ nonce = decnonce(newbuf[i]);
+ if (bitfury_checkresults(thr, info->owork, nonce))
+ info->nonces++;
}
}
- info->results_n = results_num;
memcpy(op, p, sizeof(struct bitfury_payload));
memcpy(oldbuf, newbuf, 17 * 4);