From de4c6c29d77a906fb6d30ddabc6cc8948b632166 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 6 Feb 2012 18:12:22 +1100 Subject: [PATCH] Provide support for the submitold extension on a per-pool basis based on the value being detected in a longpoll. --- cgminer.c | 20 ++++++++++++++++---- miner.h | 1 + util.c | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cgminer.c b/cgminer.c index dfb21b02..cdc6a47f 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 db701a6f..44e6a537 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 ef0a6353..9a8f08e4 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*/