Set the diff as a double sdiff from gbt solo data.
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
diff --git a/cgminer.c b/cgminer.c
index f40b0bc..6783293 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2201,6 +2201,8 @@ static void gbt_merkle_bins(struct pool *pool, json_t *transaction_arr)
pool->txn_data[0] = NULL;
}
+static double diff_from_target(void *target);
+
static const char scriptsig_header[] = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff";
static unsigned char scriptsig_header_bin[41];
@@ -2253,6 +2255,7 @@ static bool gbt_solo_decode(struct pool *pool, json_t *res_val)
hex2bin(hash_swap, target, 32);
swab256(pool->gbt_target, hash_swap);
+ pool->sdiff = diff_from_target(pool->gbt_target);
pool->gbt_version = htobe32(version);
pool->curtime = htobe32(curtime);
@@ -3428,6 +3431,17 @@ static double le256todouble(const void *target)
return dcut64;
}
+static double diff_from_target(void *target)
+{
+ double d64, dcut64;
+
+ d64 = truediffone;
+ dcut64 = le256todouble(target);
+ if (unlikely(!dcut64))
+ dcut64 = 1;
+ return d64 / dcut64;
+}
+
/*
* Calculate the work->work_difficulty based on the work->target
*/
@@ -3439,15 +3453,9 @@ static void calc_diff(struct work *work, double known)
if (known)
work->work_difficulty = known;
- else {
- double d64, dcut64;
+ else
+ work->work_difficulty = diff_from_target(work->target);
- d64 = truediffone;
- dcut64 = le256todouble(work->target);
- if (unlikely(!dcut64))
- dcut64 = 1;
- work->work_difficulty = d64 / dcut64;
- }
difficulty = work->work_difficulty;
pool_stats->last_diff = difficulty;