Provide support for the submitold extension on a per-pool basis based on the value being detected in a longpoll.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
diff --git a/cgminer.c b/cgminer.c
index dfb21b0..cdc6a47 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1740,11 +1740,17 @@ static void *submit_work_thread(void *userdata)
pthread_detach(pthread_self());
- if (!opt_submit_stale && stale_work(work, true)) {
- applog(LOG_NOTICE, "Stale share detected, discarding");
+ if (stale_work(work, true)) {
total_stale++;
pool->stale_shares++;
- goto out;
+ if (!opt_submit_stale && !pool->submit_old) {
+ applog(LOG_NOTICE, "Stale share detected, discarding");
+ goto out;
+ }
+ if (opt_submit_stale)
+ applog(LOG_NOTICE, "Stale share detected, submitting as user requested");
+ else if (pool->submit_old)
+ applog(LOG_NOTICE, "Stale share detected, submitting as pool requested");
}
/* submit solution to bitcoin via JSON-RPC */
@@ -3378,7 +3384,6 @@ static void *longpoll_thread(void *userdata)
CURL *curl = NULL;
int failures = 0;
bool rolltime;
- json_t *val;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
pthread_detach(pthread_self());
@@ -3420,10 +3425,17 @@ new_longpoll:
applog(LOG_WARNING, "Long-polling activated for %s", lp_url);
while (1) {
+ json_t *val, *soval;
+
gettimeofday(&start, NULL);
val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req,
false, true, &rolltime, pool, false);
if (likely(val)) {
+ soval = json_object_get(json_object_get(val, "result"), "submitold");
+ if (soval)
+ pool->submit_old = json_is_true(soval);
+ else
+ pool->submit_old = false;
convert_to_work(val, rolltime, pool);
failures = 0;
json_decref(val);
diff --git a/miner.h b/miner.h
index db701a6..44e6a53 100644
--- a/miner.h
+++ b/miner.h
@@ -626,6 +626,7 @@ struct pool {
bool lagging;
bool probed;
bool enabled;
+ bool submit_old;
char *hdr_path;
diff --git a/util.c b/util.c
index ef0a635..9a8f08e 100644
--- a/util.c
+++ b/util.c
@@ -374,7 +374,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
headers = curl_slist_append(headers,
"Content-type: application/json");
headers = curl_slist_append(headers,
- "X-Mining-Extensions: longpoll midstate rollntime");
+ "X-Mining-Extensions: longpoll midstate rollntime submitold");
headers = curl_slist_append(headers, len_hdr);
headers = curl_slist_append(headers, user_agent_hdr);
headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/