Browse Source

Merge branch 'stratum_fp_diff' into bfgminer

Luke Dashjr 13 years ago
parent
commit
f9f32c26c1
2 changed files with 13 additions and 3 deletions
  1. 9 1
      miner.c
  2. 4 2
      util.c

+ 9 - 1
miner.c

@@ -5917,12 +5917,20 @@ static void set_work_target(struct work *work, int diff)
 	unsigned char rtarget[36], target[36];
 	uint64_t *data64, h64;
 
+	if (!diff) {
+		// Special support is needed for difficulties < 1
+		memset(target, 0xff, 28);
+		memset(&target[28], 0, 4);
+		goto havetarget;
+	}
+
 	h64 = diffone;
 	h64 /= (uint64_t)diff;
 	memset(rtarget, 0, 32);
 	data64 = (uint64_t *)(rtarget + 4);
 	*data64 = htobe64(h64);
 	swab256(target, rtarget);
+havetarget:
 	if (opt_debug) {
 		char *htarget = bin2hex(target, 32);
 
@@ -6022,7 +6030,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
 	work->longpoll = false;
 	work->getwork_mode = GETWORK_MODE_STRATUM;
 	work->work_restart_id = work->pool->work_restart_id;
-	calc_diff(work, work->sdiff);
+	calc_diff(work, 0);
 
 	gettimeofday(&work->tv_staged, NULL);
 }

+ 4 - 2
util.c

@@ -1119,11 +1119,13 @@ static bool parse_notify(struct pool *pool, json_t *val)
 
 static bool parse_diff(struct pool *pool, json_t *val)
 {
+	double fpdiff;
 	int diff;
 
-	diff = json_integer_value(json_array_get(val, 0));
-	if (diff < 1)
+	fpdiff = json_number_value(json_array_get(val, 0));
+	if (fpdiff < 0.9999)
 		return false;
+	diff = floor(fpdiff);
 
 	mutex_lock(&pool->pool_lock);
 	pool->swork.diff = diff;