Browse Source

Explicitly probe each pool to see if work can be retrieved from it and what it supports.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
81ff7fb3dc
  1. 32
      main.c
  2. 1
      miner.h
  3. 15
      util.c

32
main.c

@ -2474,6 +2474,38 @@ int main (int argc, char *argv[]) @@ -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)) {

1
miner.h

@ -270,6 +270,7 @@ struct pool { @@ -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;

15
util.c

@ -246,7 +246,7 @@ static bool comms_error = false; @@ -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, @@ -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, @@ -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, @@ -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);

Loading…
Cancel
Save