mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-08 22:08:02 +00:00
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.
This commit is contained in:
parent
32bc746178
commit
b30ae4a216
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user