mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Store whether each server supports X-Roll-Ntime or not.
This commit is contained in:
parent
321c4798d4
commit
0ce3df10d2
6
main.c
6
main.c
@ -775,7 +775,7 @@ static bool submit_upstream_work(const struct work *work)
|
|||||||
applog(LOG_DEBUG, "DBG: sending RPC call: %s", s);
|
applog(LOG_DEBUG, "DBG: sending RPC call: %s", s);
|
||||||
|
|
||||||
/* issue JSON-RPC request */
|
/* issue JSON-RPC request */
|
||||||
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, s, false, false);
|
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, s, false, false, false, pool);
|
||||||
if (unlikely(!val)) {
|
if (unlikely(!val)) {
|
||||||
applog(LOG_INFO, "submit_upstream_work json_rpc_call failed");
|
applog(LOG_INFO, "submit_upstream_work json_rpc_call failed");
|
||||||
if (!pool_tset(pool, &pool->submit_fail)) {
|
if (!pool_tset(pool, &pool->submit_fail)) {
|
||||||
@ -847,7 +847,7 @@ static bool get_upstream_work(struct work *work)
|
|||||||
}
|
}
|
||||||
|
|
||||||
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req,
|
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req,
|
||||||
want_longpoll, false);
|
want_longpoll, false, false, pool);
|
||||||
if (unlikely(!val)) {
|
if (unlikely(!val)) {
|
||||||
applog(LOG_DEBUG, "Failed json_rpc_call in get_upstream_work");
|
applog(LOG_DEBUG, "Failed json_rpc_call in get_upstream_work");
|
||||||
goto out;
|
goto out;
|
||||||
@ -2031,7 +2031,7 @@ next_path:
|
|||||||
|
|
||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, NULL);
|
||||||
val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req,
|
val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req,
|
||||||
false, true);
|
false, true, false, pool);
|
||||||
if (likely(val)) {
|
if (likely(val)) {
|
||||||
/* Keep track of who ordered a restart_threads to make
|
/* Keep track of who ordered a restart_threads to make
|
||||||
* sure it's only done once per new block */
|
* sure it's only done once per new block */
|
||||||
|
6
miner.h
6
miner.h
@ -175,12 +175,15 @@ static inline void swap256(void *dest_p, const void *src_p)
|
|||||||
dest[7] = src[0];
|
dest[7] = src[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct pool;
|
||||||
|
|
||||||
extern bool opt_debug;
|
extern bool opt_debug;
|
||||||
extern bool opt_protocol;
|
extern bool opt_protocol;
|
||||||
extern bool opt_log_output;
|
extern bool opt_log_output;
|
||||||
extern const uint32_t sha256_init_state[];
|
extern const uint32_t sha256_init_state[];
|
||||||
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
|
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
|
||||||
const char *rpc_req, bool, bool);
|
const char *rpc_req, bool, bool, bool,
|
||||||
|
struct pool *pool);
|
||||||
extern char *bin2hex(const unsigned char *p, size_t len);
|
extern char *bin2hex(const unsigned char *p, size_t len);
|
||||||
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
|
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
|
||||||
|
|
||||||
@ -267,6 +270,7 @@ struct pool {
|
|||||||
bool submit_fail;
|
bool submit_fail;
|
||||||
bool localgen;
|
bool localgen;
|
||||||
bool idlenet;
|
bool idlenet;
|
||||||
|
bool has_rolltime;
|
||||||
unsigned int getwork_requested;
|
unsigned int getwork_requested;
|
||||||
unsigned int stale_shares;
|
unsigned int stale_shares;
|
||||||
unsigned int discarded_work;
|
unsigned int discarded_work;
|
||||||
|
13
util.c
13
util.c
@ -186,7 +186,8 @@ static size_t upload_data_cb(void *ptr, size_t size, size_t nmemb,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
|
static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data,
|
||||||
|
struct pool *pool)
|
||||||
{
|
{
|
||||||
struct header_info *hi = user_data;
|
struct header_info *hi = user_data;
|
||||||
size_t remlen, slen, ptrlen = size * nmemb;
|
size_t remlen, slen, ptrlen = size * nmemb;
|
||||||
@ -225,6 +226,11 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
|
|||||||
if (opt_protocol)
|
if (opt_protocol)
|
||||||
applog(LOG_DEBUG, "HTTP hdr(%s): %s", key, val);
|
applog(LOG_DEBUG, "HTTP hdr(%s): %s", key, val);
|
||||||
|
|
||||||
|
if (!strcasecmp("X-Roll-Ntime", key)) {
|
||||||
|
applog(LOG_INFO, "X-Roll-Ntime found");
|
||||||
|
pool->has_rolltime = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcasecmp("X-Long-Polling", key)) {
|
if (!strcasecmp("X-Long-Polling", key)) {
|
||||||
hi->lp_path = val; /* steal memory reference */
|
hi->lp_path = val; /* steal memory reference */
|
||||||
val = NULL;
|
val = NULL;
|
||||||
@ -240,7 +246,8 @@ 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 longpoll_scan, bool longpoll,
|
||||||
|
bool getroll, struct pool *pool)
|
||||||
{
|
{
|
||||||
json_t *val, *err_val, *res_val;
|
json_t *val, *err_val, *res_val;
|
||||||
int rc;
|
int rc;
|
||||||
@ -271,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 (lp_scanning || getroll) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user