mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 15:27:53 +00:00
Explicitly probe each pool to see if work can be retrieved from it and what it supports.
This commit is contained in:
parent
913e120262
commit
81ff7fb3dc
32
main.c
32
main.c
@ -2474,6 +2474,38 @@ int main (int argc, char *argv[])
|
|||||||
} else
|
} else
|
||||||
longpoll_thr_id = -1;
|
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 ) {
|
if (opt_n_threads ) {
|
||||||
cpus = calloc(num_processors, sizeof(struct cgpu_info));
|
cpus = calloc(num_processors, sizeof(struct cgpu_info));
|
||||||
if (unlikely(!cpus)) {
|
if (unlikely(!cpus)) {
|
||||||
|
1
miner.h
1
miner.h
@ -270,6 +270,7 @@ struct pool {
|
|||||||
bool localgen;
|
bool localgen;
|
||||||
bool idlenet;
|
bool idlenet;
|
||||||
bool has_rolltime;
|
bool has_rolltime;
|
||||||
|
bool probed;
|
||||||
unsigned int getwork_requested;
|
unsigned int getwork_requested;
|
||||||
unsigned int stale_shares;
|
unsigned int stale_shares;
|
||||||
unsigned int discarded_work;
|
unsigned int discarded_work;
|
||||||
|
15
util.c
15
util.c
@ -246,7 +246,7 @@ static bool comms_error = false;
|
|||||||
|
|
||||||
json_t *json_rpc_call(CURL *curl, const char *url,
|
json_t *json_rpc_call(CURL *curl, const char *url,
|
||||||
const char *userpass, const char *rpc_req,
|
const char *userpass, const char *rpc_req,
|
||||||
bool longpoll_scan, bool longpoll,
|
bool probe, bool longpoll,
|
||||||
struct pool *pool)
|
struct pool *pool)
|
||||||
{
|
{
|
||||||
json_t *val, *err_val, *res_val;
|
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 len_hdr[64], user_agent_hdr[128];
|
||||||
char curl_err_str[CURL_ERROR_SIZE];
|
char curl_err_str[CURL_ERROR_SIZE];
|
||||||
struct header_info hi = { };
|
struct header_info hi = { };
|
||||||
bool lp_scanning = false;
|
bool probing = false;
|
||||||
|
|
||||||
/* it is assumed that 'curl' is freshly [re]initialized at this pt */
|
/* it is assumed that 'curl' is freshly [re]initialized at this pt */
|
||||||
|
|
||||||
if (longpoll_scan)
|
if (probe)
|
||||||
lp_scanning = want_longpoll && !have_longpoll;
|
probing = ((want_longpoll && !have_longpoll) || !pool->probed);
|
||||||
|
|
||||||
if (opt_protocol)
|
if (opt_protocol)
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
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_READDATA, &upload_data);
|
||||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_err_str);
|
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_err_str);
|
||||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
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_HEADERFUNCTION, resp_hdr_cb);
|
||||||
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &hi);
|
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);
|
tq_push(thr_info[longpoll_thr_id].q, hi.lp_path);
|
||||||
} else
|
} else
|
||||||
free(hi.lp_path);
|
free(hi.lp_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (probing) {
|
||||||
|
pool->probed = true;
|
||||||
pool->has_rolltime = hi.has_rolltime;
|
pool->has_rolltime = hi.has_rolltime;
|
||||||
}
|
}
|
||||||
|
|
||||||
hi.lp_path = NULL;
|
hi.lp_path = NULL;
|
||||||
|
|
||||||
val = JSON_LOADS(all_data.buf, &err);
|
val = JSON_LOADS(all_data.buf, &err);
|
||||||
|
Loading…
Reference in New Issue
Block a user