Browse Source

Allow arbitrary diffs to be tested against nonces via a test_nonce_diff function.

Con Kolivas 12 years ago
parent
commit
ac5b12e1a0
2 changed files with 13 additions and 0 deletions
  1. 12 0
      cgminer.c
  2. 1 0
      miner.h

+ 12 - 0
cgminer.c

@@ -6104,6 +6104,18 @@ bool test_nonce(struct work *work, uint32_t nonce)
 	return (be32toh(hash2_32[7]) <= diff1targ);
 }
 
+bool test_nonce_diff(struct work *work, uint32_t nonce, double diff)
+{
+	uint32_t hash2_be[8];
+	uint64_t *hashbe64 = (uint64_t *)hash2_be, hash64, diff64;
+
+	diff64 = (double)0x00000000ffff0000ULL / diff;
+	rebuild_hash2(work, nonce);
+	swap256(hash2_be, work->hash2);
+	hash64 = be64toh(*hashbe64);
+	return hash64 <= diff64;
+}
+
 static void update_work_stats(struct thr_info *thr, struct work *work)
 {
 	work->share_diff = share_diff(work);

+ 1 - 0
miner.h

@@ -1490,6 +1490,7 @@ struct modminer_fpga_state {
 extern void get_datestamp(char *, size_t, struct timeval *);
 extern void inc_hw_errors(struct thr_info *thr);
 extern bool test_nonce(struct work *work, uint32_t nonce);
+extern bool test_nonce_diff(struct work *work, uint32_t nonce, double diff);
 extern void submit_tested_work(struct thr_info *thr, struct work *work);
 extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
 extern bool submit_noffset_nonce(struct thr_info *thr, struct work *work, uint32_t nonce,