Browse Source

Stratum: If the pool target has changed since the job a work came from, check any shares against the new target too in case it expects retroactive difficulty adjustments

Luke Dashjr 12 years ago
parent
commit
d480a6deb6
1 changed files with 17 additions and 1 deletions
  1. 17 1
      miner.c

+ 17 - 1
miner.c

@@ -9157,7 +9157,23 @@ enum test_nonce2_result hashtest2(struct work *work, bool checktarget)
 		return TNR_GOOD;
 		return TNR_GOOD;
 
 
 	if (!hash_target_check_v(work->hash, work->target))
 	if (!hash_target_check_v(work->hash, work->target))
-		return TNR_HIGH;
+	{
+		bool high_hash = true;
+		struct pool * const pool = work->pool;
+		if (pool->stratum_active)
+		{
+			// Some stratum pools are buggy and expect difficulty changes to be immediate retroactively, so if the target has changed, check and submit just in case
+			if (memcmp(pool->swork.target, work->target, sizeof(work->target)))
+			{
+				applog(LOG_DEBUG, "Stratum pool %u target has changed since work job issued, checking that too",
+				       pool->pool_no);
+				if (hash_target_check_v(work->hash, pool->swork.target))
+					high_hash = false;
+			}
+		}
+		if (high_hash)
+			return TNR_HIGH;
+	}
 
 
 	return TNR_GOOD;
 	return TNR_GOOD;
 }
 }