Explicitly probe each pool to see if work can be retrieved from it and what it supports.
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
diff --git a/main.c b/main.c
index 096915d..1308eb1 100644
--- a/main.c
+++ b/main.c
@@ -2474,6 +2474,38 @@ int main (int argc, char *argv[])
} else
longpoll_thr_id = -1;
+ /* Test each pool to see if we can retrieve and use work and for what
+ * it supports */
+ for (i = 0; i < total_pools; i++) {
+ struct pool *pool;
+ struct work work;
+ json_t *val;
+ CURL *curl;
+
+ curl = curl_easy_init();
+ if (unlikely(!curl)) {
+ applog(LOG_ERR, "CURL initialisation failed");
+ return 1;
+ }
+
+ pool = &pools[i];
+ val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req,
+ true, false, pool);
+
+ if (val) {
+ bool rc;
+
+ rc = work_decode(json_object_get(val, "result"), &work);
+ if (rc)
+ applog(LOG_INFO, "Successfully retreived and deciphered work from pool %u %s", i, pool->rpc_url);
+ else
+ applog(LOG_WARNING, "Successfully retreived but FAILED to decipher work from pool %u %s", i, pool->rpc_url);
+ json_decref(val);
+ } else
+ applog(LOG_WARNING, "FAILED to retrieve work from pool %u %s", i, pool->rpc_url);
+ curl_easy_cleanup(curl);
+ }
+
if (opt_n_threads ) {
cpus = calloc(num_processors, sizeof(struct cgpu_info));
if (unlikely(!cpus)) {
diff --git a/miner.h b/miner.h
index 1442be0..63ab517 100644
--- a/miner.h
+++ b/miner.h
@@ -270,6 +270,7 @@ struct pool {
bool localgen;
bool idlenet;
bool has_rolltime;
+ bool probed;
unsigned int getwork_requested;
unsigned int stale_shares;
unsigned int discarded_work;
diff --git a/util.c b/util.c
index cabcfa7..75ee5d4 100644
--- a/util.c
+++ b/util.c
@@ -246,7 +246,7 @@ static bool comms_error = false;
json_t *json_rpc_call(CURL *curl, const char *url,
const char *userpass, const char *rpc_req,
- bool longpoll_scan, bool longpoll,
+ bool probe, bool longpoll,
struct pool *pool)
{
json_t *val, *err_val, *res_val;
@@ -258,12 +258,12 @@ json_t *json_rpc_call(CURL *curl, const char *url,
char len_hdr[64], user_agent_hdr[128];
char curl_err_str[CURL_ERROR_SIZE];
struct header_info hi = { };
- bool lp_scanning = false;
+ bool probing = false;
/* it is assumed that 'curl' is freshly [re]initialized at this pt */
- if (longpoll_scan)
- lp_scanning = want_longpoll && !have_longpoll;
+ if (probe)
+ probing = ((want_longpoll && !have_longpoll) || !pool->probed);
if (opt_protocol)
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
@@ -278,7 +278,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_data);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_err_str);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
- if (lp_scanning) {
+ if (probing) {
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, resp_hdr_cb);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &hi);
}
@@ -329,8 +329,13 @@ json_t *json_rpc_call(CURL *curl, const char *url,
tq_push(thr_info[longpoll_thr_id].q, hi.lp_path);
} else
free(hi.lp_path);
+ }
+
+ if (probing) {
+ pool->probed = true;
pool->has_rolltime = hi.has_rolltime;
}
+
hi.lp_path = NULL;
val = JSON_LOADS(all_data.buf, &err);