Commit 48caf248a7f124787667aae4ca5f4160c4e601a4

Con Kolivas 2011-07-02T09:39:43

Check for stale block after failed submission as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/cpu-miner.c b/cpu-miner.c
index 5f9c4cf..6294d37 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -544,6 +544,10 @@ static void *submit_work_thread(void *userdata)
 
 	/* submit solution to bitcoin via JSON-RPC */
 	while (!submit_upstream_work(curl, wc->u.work)) {
+		if (unlikely(strncmp((const char *)wc->u.work->data, current_block, 36))) {
+			applog(LOG_INFO, "Stale work detected, discarding");
+			goto out;
+		}
 		if (unlikely((opt_retries >= 0) && (++failures > opt_retries))) {
 			applog(LOG_ERR, "Failed %d retries ...terminating workio thread", opt_retries);
 			kill_work();