diff --git a/api.c b/api.c index 50b75287..8a6a28c1 100644 --- a/api.c +++ b/api.c @@ -27,6 +27,7 @@ #include "compat.h" #include "miner.h" +#include "pool.h" #include "util.h" // BUFSIZ varies on Windows and Linux diff --git a/configure.ac b/configure.ac index e7eed741..4665da20 100644 --- a/configure.ac +++ b/configure.ac @@ -258,6 +258,7 @@ if test "x$have_sgminer_sdk" = "xtrue"; then fi PKG_CONFIG="${PKG_CONFIG:-pkg-config} --define-variable=arch=$ARCH_DIR --define-variable=target=$target --define-variable=sgminersdkdir=$SGMINER_SDK" PKG_CONFIG_PATH="$SGMINER_SDK/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" + export PKG_CONFIG_PATH fi AC_ARG_ENABLE([libcurl], diff --git a/miner.h b/miner.h index ebdc5795..6094e7f2 100644 --- a/miner.h +++ b/miner.h @@ -1175,6 +1175,7 @@ struct pool { char *name; char *description; int prio; + bool extranonce_subscribe; int accepted, rejected; int seq_rejects; int seq_getfails; diff --git a/sgminer.c b/sgminer.c index dfa5cc23..d187e7b9 100644 --- a/sgminer.c +++ b/sgminer.c @@ -151,7 +151,6 @@ bool opt_api_network; bool opt_delaynet; bool opt_disable_pool; bool opt_disable_client_reconnect = false; -bool opt_extranonce_subscribe = true; static bool no_work; bool opt_worktime; #if defined(HAVE_LIBCURL) && defined(CURL_HAS_KEEPALIVE) @@ -563,6 +562,7 @@ struct pool *add_pool(void) pool->rpc_proxy = NULL; pool->quota = 1; adjust_quota_gcd(); + pool->extranonce_subscribe = true; pool->description = ""; @@ -951,6 +951,16 @@ static char *set_userpass(const char *arg) return NULL; } +static char *set_no_extranonce_subscribe(char *arg) +{ + struct pool *pool = get_current_pool(); + + applog(LOG_DEBUG, "Disable extranonce subscribe on %d", pool->pool_no); + opt_set_invbool(&pool->extranonce_subscribe); + + return NULL; +} + static char *set_pool_priority(char *arg) { struct pool *pool = get_current_pool(); @@ -1329,7 +1339,7 @@ static struct opt_table opt_config_table[] = { opt_set_invbool, &opt_submit_stale, "Don't submit shares if they are detected as stale"), OPT_WITHOUT_ARG("--no-extranonce-subscribe", - opt_set_invbool, &opt_extranonce_subscribe, + set_no_extranonce_subscribe, NULL, "Disable 'extranonce' stratum subscribe"), OPT_WITH_ARG("--pass|-p", set_pass, NULL, NULL, @@ -4302,6 +4312,8 @@ void write_config(FILE *fcfg) pool->rpc_proxy ? "|" : "", json_escape(pool->rpc_url)); } + if (!pool->extranonce_subscribe) + fputs("\n\t\t\"no-extranonce-subscribe\" : true,", fcfg); fprintf(fcfg, "\n\t\t\"user\" : \"%s\",", json_escape(pool->rpc_user)); fprintf(fcfg, "\n\t\t\"pass\" : \"%s\",", json_escape(pool->rpc_pass)); /* Using get_pool_name() here is unsafe if opt_incognito is true. */ @@ -5687,7 +5699,7 @@ retry_stratum: bool init = pool_tset(pool, &pool->stratum_init); if (!init) { - bool ret = initiate_stratum(pool) && (!opt_extranonce_subscribe || subscribe_extranonce(pool)) && auth_stratum(pool); + bool ret = initiate_stratum(pool) && (!pool->extranonce_subscribe || subscribe_extranonce(pool)) && auth_stratum(pool); if (ret) init_stratum_threads(pool); diff --git a/util.c b/util.c index 8f0c20d7..8d78481c 100644 --- a/util.c +++ b/util.c @@ -1907,8 +1907,15 @@ bool subscribe_extranonce(struct pool *pool) char *ss; if (err_val) { - ss = (char *)json_string_value(json_array_get(err_val, 1)); - if (opt_extranonce_subscribe && strcmp(ss, "Method 'subscribe' not found for service 'mining.extranonce'") == 0) { + ss = __json_array_string(err_val, 1); + if (!ss) + ss = (char *)json_string_value(err_val); + if (ss && (strcmp(ss, "Method 'subscribe' not found for service 'mining.extranonce'") == 0)) { + applog(LOG_INFO, "Cannot subscribe to mining.extranonce on %s", get_pool_name(pool)); + ret = true; + goto out; + } + if (ss && (strcmp(ss, "Unrecognized request provided") == 0)) { applog(LOG_INFO, "Cannot subscribe to mining.extranonce on %s", get_pool_name(pool)); ret = true; goto out; @@ -2561,7 +2568,7 @@ bool restart_stratum(struct pool *pool) suspend_stratum(pool); if (!initiate_stratum(pool)) return false; - if (opt_extranonce_subscribe && !subscribe_extranonce(pool)) + if (pool->extranonce_subscribe && !subscribe_extranonce(pool)) return false; if (!auth_stratum(pool)) return false;