Rationalise diffs stored in the work struct and document them to avoid further confusion
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
diff --git a/cgminer.c b/cgminer.c
index e77da7f..265dd99 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6751,7 +6751,6 @@ void submit_nonce2_nonce(struct thr_info *thr, uint32_t pool_no, uint32_t nonce2
pool->nonce2 = nonce2;
gen_stratum_work(pool, work);
- work->device_diff = MIN(drv->working_diff, work->work_difficulty);
submit_nonce(thr, work, nonce);
free_work(work);
}
@@ -7118,9 +7117,9 @@ static void update_work_stats(struct thr_info *thr, struct work *work)
}
mutex_lock(&stats_lock);
- total_diff1 += work->device_diff;
- thr->cgpu->diff1 += work->device_diff;
- work->pool->diff1 += work->device_diff;
+ total_diff1 += work->work_difficulty;
+ thr->cgpu->diff1 += work->work_difficulty;
+ work->pool->diff1 += work->work_difficulty;
thr->cgpu->last_device_valid_work = time(NULL);
mutex_unlock(&stats_lock);
}
@@ -7249,7 +7248,7 @@ static void hash_sole_work(struct thr_info *mythr)
"mining thread %d", thr_id);
break;
}
- work->device_diff = MIN(drv->working_diff, work->work_difficulty);
+ work->device_diff = MIN(drv->max_diff, work->work_difficulty);
do {
cgtime(&tv_start);
@@ -8833,8 +8832,6 @@ void fill_device_drv(struct device_drv *drv)
drv->zero_stats = &noop_zero_stats;
if (!drv->max_diff)
drv->max_diff = 1;
- if (!drv->working_diff)
- drv->working_diff = 1;
}
void null_device_drv(struct device_drv *drv)
@@ -8870,7 +8867,6 @@ void null_device_drv(struct device_drv *drv)
drv->zero_stats = &noop_zero_stats;
drv->max_diff = 1;
- drv->working_diff = 1;
}
void enable_device(struct cgpu_info *cgpu)
diff --git a/driver-hashfast.c b/driver-hashfast.c
index ab18804..8227416 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -1934,7 +1934,7 @@ struct device_drv hashfast_drv = {
.drv_id = DRIVER_hashfast,
.dname = "Hashfast",
.name = "HFA",
- .max_diff = 256.0, // Limit max diff to get some nonces back regardless
+ .max_diff = 32.0, // Limit max diff to get some nonces back regardless
.drv_detect = hfa_detect,
.thread_init = hfa_init,
.hash_work = &hash_driver_work,
diff --git a/driver-spondoolies.c b/driver-spondoolies.c
index 73d74a1..6aa66cf 100644
--- a/driver-spondoolies.c
+++ b/driver-spondoolies.c
@@ -223,7 +223,7 @@ static void fill_minergate_request(minergate_do_job_req* work, struct work *cg_w
int ntime_offset)
{
uint32_t x[64/4];
- int wd;
+ uint64_t wd;
memset(work, 0, sizeof(minergate_do_job_req));
//work->
@@ -237,7 +237,7 @@ static void fill_minergate_request(minergate_do_job_req* work, struct work *cg_w
//work->leading_zeroes = get_leading_zeroes(cg_work->target);
// Is there no better way to get leading zeroes?
work->leading_zeroes = 30;
- wd = (int)round(cg_work->work_difficulty);
+ wd = round(cg_work->work_difficulty);
while (wd) {
work->leading_zeroes++;
wd = wd >> 1;
@@ -430,6 +430,7 @@ struct device_drv spondoolies_drv = {
.drv_id = DRIVER_spondoolies,
.dname = "Spondoolies",
.name = "SPN",
+ .max_diff = 32.0, // Limit max diff to get some nonces back regardless
.drv_detect = spondoolies_detect,
.get_api_stats = spondoolies_api_stats,
.thread_prepare = spondoolies_prepare,
diff --git a/miner.h b/miner.h
index f25dc78..388c433 100644
--- a/miner.h
+++ b/miner.h
@@ -351,7 +351,6 @@ struct device_drv {
/* Highest target diff the device supports */
double max_diff;
- double working_diff;
};
extern struct device_drv *copy_drv(struct device_drv*);
@@ -1303,7 +1302,8 @@ struct work {
unsigned char target[32];
unsigned char hash[32];
- unsigned char device_target[32];
+ /* This is the diff the device is currently aiming for and must be
+ * the minimum of work_difficulty & drv->max_diff */
double device_diff;
uint64_t share_diff;
@@ -1341,6 +1341,8 @@ struct work {
uint32_t id;
UT_hash_handle hh;
+ /* This is the diff work we're aiming to submit and should match the
+ * work->target binary */
double work_difficulty;
// Allow devices to identify work if multiple sub-devices