From 5a3b374962d8847fab1994e7943008c51789f182 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 25 Feb 2013 08:59:11 +1100 Subject: [PATCH 1/3] Update copyright dates. --- cgminer.c | 2 +- util.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cgminer.c b/cgminer.c index e35814f3..0ec9d541 100644 --- a/cgminer.c +++ b/cgminer.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2012 Con Kolivas + * Copyright 2011-2013 Con Kolivas * Copyright 2011-2012 Luke Dashjr * Copyright 2010 Jeff Garzik * diff --git a/util.c b/util.c index cd08979c..d433e106 100644 --- a/util.c +++ b/util.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2012 Con Kolivas + * Copyright 2011-2013 Con Kolivas * Copyright 2010 Jeff Garzik * * This program is free software; you can redistribute it and/or modify it From d9d5a1a0b6fce693acc0edb65fc6e5d054c589c3 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 25 Feb 2013 09:15:20 +1100 Subject: [PATCH 2/3] Speed up watchdog interval and therefore display updates to 2 seconds. --- cgminer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgminer.c b/cgminer.c index 0ec9d541..69809889 100644 --- a/cgminer.c +++ b/cgminer.c @@ -5843,7 +5843,7 @@ static void *watchpool_thread(void __maybe_unused *userdata) /* Makes sure the hashmeter keeps going even if mining threads stall, updates * the screen at regular intervals, and restarts threads if they appear to have * died. */ -#define WATCHDOG_INTERVAL 3 +#define WATCHDOG_INTERVAL 2 #define WATCHDOG_SICK_TIME 60 #define WATCHDOG_DEAD_TIME 600 #define WATCHDOG_SICK_COUNT (WATCHDOG_SICK_TIME/WATCHDOG_INTERVAL) From 3c949e5f6cc53089258e60662f5553069b4acd23 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 25 Feb 2013 10:38:28 +1100 Subject: [PATCH 3/3] Try to extract the sessionid associated with mining.notify on 3rd level array and submit it along with the userid to support mining resume, failing gracefully and restarting if the pool rejects it. --- util.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/util.c b/util.c index d433e106..282b7494 100644 --- a/util.c +++ b/util.c @@ -1424,6 +1424,34 @@ static bool setup_stratum_curl(struct pool *pool) return true; } +static char *get_sessionid(json_t *val) +{ + char *ret = NULL; + json_t *arr_val; + int arrsize, i; + + arr_val = json_array_get(val, 0); + if (!arr_val || !json_is_array(arr_val)) + goto out; + arrsize = json_array_size(arr_val); + for (i = 0; i < arrsize; i++) { + json_t *arr = json_array_get(arr_val, i); + char *notify; + + if (!arr | !json_is_array(arr)) + break; + notify = __json_array_string(arr, 0); + if (!notify) + continue; + if (!strncasecmp(notify, "mining.notify", 13)) { + ret = json_array_string(arr, 1); + break; + } + } +out: + return ret; +} + bool initiate_stratum(struct pool *pool) { char s[RBUFSIZE], *sret = NULL, *nonce1, *sessionid; @@ -1436,9 +1464,12 @@ bool initiate_stratum(struct pool *pool) goto out; resend: - if (pool->sessionid) - sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\"%s\"]}", swork_id++, pool->sessionid); - else + if (!recvd) { + if (pool->sessionid) + sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\", \"%s\"]}", swork_id++, pool->sessionid); + else + sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\"]}", swork_id++); + } else sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++); if (!__stratum_send(pool, s, strlen(s))) { @@ -1483,7 +1514,7 @@ resend: goto out; } - sessionid = json_array_string(json_array_get(res_val, 0), 1); + sessionid = get_sessionid(res_val); if (!sessionid) applog(LOG_DEBUG, "Failed to get sessionid in initiate_stratum"); nonce1 = json_array_string(res_val, 1); @@ -1525,7 +1556,7 @@ out: pool->pool_no, pool->nonce1, pool->n2size); } } else { - if (recvd && pool->sessionid) { + if (recvd) { /* Reset the sessionid used for stratum resuming in case the pool * does not support it, or does not know how to respond to the * presence of the sessionid parameter. */