Browse Source

longpoll: auto disable gbt when not supported

master
Tanguy Pruvot 10 years ago
parent
commit
7f00bce5ae
  1. 11
      ccminer.cpp
  2. 13
      util.cpp

11
ccminer.cpp

@ -740,11 +740,18 @@ static bool get_blocktemplate(CURL *curl, struct work *work) @@ -740,11 +740,18 @@ static bool get_blocktemplate(CURL *curl, struct work *work)
if (!allow_gbt)
return false;
int curl_err = 0;
json_t *val = json_rpc_call(curl, rpc_url, rpc_userpass, gbt_req,
want_longpoll, false, NULL);
want_longpoll, have_longpoll, &curl_err);
if (!val)
if (!val && curl_err == -1) {
// when getblocktemplate is not supported, disable it
allow_gbt = false;
if (!opt_quiet) {
applog(LOG_BLUE, "gbt not supported, block height notices disabled");
}
return false;
}
bool rc = gbt_work_decode(json_object_get(val, "result"), work);

13
util.cpp

@ -526,11 +526,22 @@ json_t *json_rpc_call(CURL *curl, const char *url, @@ -526,11 +526,22 @@ json_t *json_rpc_call(CURL *curl, const char *url,
if (err_val) {
json_t *msg = json_object_get(err_val, "message");
s = json_dumps(err_val, JSON_INDENT(3));
json_t *err_code = json_object_get(err_val, "code");
if (curl_err && json_integer_value(err_code))
*curl_err = (int) json_integer_value(err_code);
json_decref(err_code);
s = json_dumps(err_val, 0);
if (json_is_string(msg)) {
free(s);
s = strdup(json_string_value(msg));
if (have_longpoll && s && !strcmp(s, "method not getwork")) {
json_decref(err_val);
free(s);
goto err_out;
}
}
json_decref(err_val);
}
else
s = strdup("(unknown reason)");

Loading…
Cancel
Save