diff --git a/cgminer.c b/cgminer.c index de172305..58d0211a 100644 --- a/cgminer.c +++ b/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); diff --git a/miner.h b/miner.h index f39a7d7b..a8014279 100644 --- a/miner.h +++ b/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,