From 61392dc673a92f95905c4a46436e680568f4c429 Mon Sep 17 00:00:00 2001 From: pooler Date: Sun, 12 Feb 2012 19:50:59 +0100 Subject: [PATCH] Support for "submitold" extension to long polling --- cpu-miner.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cpu-miner.c b/cpu-miner.c index 57d939d..9caa834 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -93,6 +93,7 @@ bool opt_debug = false; bool opt_protocol = false; bool want_longpoll = true; bool have_longpoll = false; +static bool submit_old = false; bool use_syslog = false; static bool opt_quiet = false; static int opt_retries = -1; @@ -234,6 +235,10 @@ static bool submit_upstream_work(CURL *curl, const struct work *work) int i; bool rc = false; + /* pass if the previous hash is not the current previous hash */ + if (!submit_old && memcmp(work->data + 4, g_work.data + 4, 32)) + return true; + /* build hex string */ hexstr = bin2hex(work->data, sizeof(work->data)); if (unlikely(!hexstr)) { @@ -618,13 +623,15 @@ start: applog(LOG_INFO, "Long-polling activated for %s", lp_url); while (1) { - json_t *val; + json_t *val, *soval; int err; val = json_rpc_call(curl, lp_url, rpc_userpass, rpc_req, false, true, &err); if (likely(val)) { applog(LOG_INFO, "LONGPOLL detected new block"); + soval = json_object_get(json_object_get(val, "result"), "submitold"); + submit_old = soval ? json_is_true(soval) : false; pthread_mutex_lock(&g_work_lock); if (work_decode(json_object_get(val, "result"), &g_work)) { if (opt_debug)