Use fractional hashrate return values in bitfury_scanhash to minimise the number of times we return 0 based on hashrate so far to further damp out displayed hashrate.
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 2fbe125..0cb9fef 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -142,6 +142,9 @@ static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_device
if (!info)
quit(1, "Failed to calloc info in bitfury_detect_one");
bitfury->device_data = info;
+ /* This does not artificially raise hashrate, it simply allows the
+ * hashrate to adapt quickly on starting. */
+ info->total_nonces = 1;
usb_buffer_enable(bitfury);
@@ -223,6 +226,8 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
struct cgpu_info *bitfury = thr->cgpu;
struct bitfury_info *info = bitfury->device_data;
struct timeval tv_now;
+ double nonce_rate;
+ int64_t ret = 0;
int amount, i;
char buf[45];
int ms_diff;
@@ -295,23 +300,30 @@ cascade:
info->prevwork[i] = info->prevwork[i - 1];
info->prevwork[0] = copy_work(work);
work->blk.nonce = 0xffffffff;
- if (info->nonces) {
- info->nonces--;
- return (int64_t)0xffffffff;
+
+ info->cycles++;
+ info->total_nonces += info->nonces;
+ info->saved_nonces += info->nonces;
+ info->nonces = 0;
+ nonce_rate = (double)info->total_nonces / (double)info->cycles;
+ if (info->saved_nonces >= nonce_rate) {
+ info->saved_nonces -= nonce_rate;
+ ret = (double)0xffffffff * nonce_rate;
}
if (unlikely(bitfury->usbinfo.nodev)) {
applog(LOG_WARNING, "%s %d: Device disappeared, disabling thread",
bitfury->drv->name, bitfury->device_id);
- return -1;
+ ret = -1;
}
- return 0;
+ return ret;
}
static struct api_data *bitfury_api_stats(struct cgpu_info *cgpu)
{
struct bitfury_info *info = cgpu->device_data;
struct api_data *root = NULL;
+ double nonce_rate;
char serial[16];
int version;
@@ -320,6 +332,8 @@ static struct api_data *bitfury_api_stats(struct cgpu_info *cgpu)
root = api_add_string(root, "Product", info->product, false);
sprintf(serial, "%08x", info->serial);
root = api_add_string(root, "Serial", serial, true);
+ nonce_rate = (double)info->total_nonces / (double)info->cycles;
+ root = api_add_double(root, "NonceRate", &nonce_rate, true);
return root;
}
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 9cbe420..07e795f 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -24,6 +24,9 @@ struct bitfury_info {
char buf[512];
int tot;
int nonces;
+ int total_nonces;
+ double saved_nonces;
+ int cycles;
struct timeval tv_start;
};