Abstract out work submission once it's been tested, to be used by drivers that do their own internal validity testing.
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 58 59 60 61
diff --git a/cgminer.c b/cgminer.c
index 77f973f..953ab02 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -6023,22 +6023,11 @@ bool test_nonce(struct work *work, uint32_t nonce)
return (be32toh(hash2_32[7]) <= diff1targ);
}
-/* Returns true if nonce for work was a valid share */
-bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
+/* To be used once the work has been tested to be meet diff1 and has had its
+ * nonce adjusted. */
+void submit_tested_work(struct thr_info *thr, struct work *work)
{
struct timeval tv_work_found;
- bool ret = true;
-
- cgtime(&tv_work_found);
-
- if (!test_nonce(work, nonce)) {
- applog(LOG_INFO, "%s%d: invalid nonce - HW error",
- thr->cgpu->drv->name, thr->cgpu->device_id);
-
- inc_hw_errors(thr);
- ret = false;
- goto out;
- }
work->share_diff = share_diff(work);
@@ -6051,11 +6040,28 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
if (!fulltest(work->hash2, work->target)) {
applog(LOG_INFO, "Share below target");
- goto out;
+ return;
}
+ cgtime(&tv_work_found);
submit_work_async(work, &tv_work_found);
-out:
+}
+
+/* Returns true if nonce for work was a valid share */
+bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
+{
+ bool ret = true;
+
+ if (test_nonce(work, nonce))
+ submit_tested_work(thr, work);
+ else {
+ applog(LOG_INFO, "%s%d: invalid nonce - HW error",
+ thr->cgpu->drv->name, thr->cgpu->device_id);
+
+ inc_hw_errors(thr);
+ ret = false;
+ }
+
return ret;
}