mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-25 14:04:25 +00:00
Send subscribe request before auth
This commit is contained in:
parent
4ad62b9a78
commit
281bcd75e9
@ -5686,7 +5686,7 @@ retry_stratum:
|
|||||||
bool init = pool_tset(pool, &pool->stratum_init);
|
bool init = pool_tset(pool, &pool->stratum_init);
|
||||||
|
|
||||||
if (!init) {
|
if (!init) {
|
||||||
bool ret = initiate_stratum(pool) && auth_stratum(pool) && (!opt_extranonce_subscribe || subscribe_extranonce(pool));
|
bool ret = initiate_stratum(pool) && (!opt_extranonce_subscribe || subscribe_extranonce(pool)) && auth_stratum(pool);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
init_stratum_threads(pool);
|
init_stratum_threads(pool);
|
||||||
|
54
util.c
54
util.c
@ -1878,7 +1878,9 @@ bool parse_method(struct pool *pool, char *s)
|
|||||||
|
|
||||||
bool subscribe_extranonce(struct pool *pool)
|
bool subscribe_extranonce(struct pool *pool)
|
||||||
{
|
{
|
||||||
char s[RBUFSIZE];
|
json_t *val = NULL, *res_val, *err_val;
|
||||||
|
char s[RBUFSIZE], *sret = NULL;
|
||||||
|
json_error_t err;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
sprintf(s, "{\"id\": %d, \"method\": \"mining.extranonce.subscribe\", \"params\": []}",
|
sprintf(s, "{\"id\": %d, \"method\": \"mining.extranonce.subscribe\", \"params\": []}",
|
||||||
@ -1887,8 +1889,54 @@ bool subscribe_extranonce(struct pool *pool)
|
|||||||
if (!stratum_send(pool, s, strlen(s)))
|
if (!stratum_send(pool, s, strlen(s)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* Parse all data in the queue and anything left should be auth */
|
||||||
|
while (42) {
|
||||||
|
if (!socket_full(pool, DEFAULT_SOCKWAIT)) {
|
||||||
|
applog(LOG_DEBUG, "Timed out waiting for response extranonce.subscribe");
|
||||||
|
/* some pool doesnt send anything, so this is normal */
|
||||||
|
ret = true;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
sret = recv_line(pool);
|
||||||
|
if (!sret)
|
||||||
|
return ret;
|
||||||
|
if (parse_method(pool, sret))
|
||||||
|
free(sret);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
val = JSON_LOADS(sret, &err);
|
||||||
|
free(sret);
|
||||||
|
res_val = json_object_get(val, "result");
|
||||||
|
err_val = json_object_get(val, "error");
|
||||||
|
|
||||||
|
if (!res_val || json_is_false(res_val) || (err_val && !json_is_null(err_val))) {
|
||||||
|
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) {
|
||||||
|
applog(LOG_INFO, "Cannot subscribe to mining.extranonce on %s", get_pool_name(pool));
|
||||||
|
ret = true;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
ss = json_dumps(err_val, JSON_INDENT(3));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ss = strdup("(unknown reason)");
|
||||||
|
applog(LOG_INFO, "%s JSON stratum auth failed: %s", get_pool_name(pool), ss);
|
||||||
|
free(ss);
|
||||||
|
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = true;
|
ret = true;
|
||||||
applog(LOG_INFO, "Stratum extranonce subscribe for %s", get_pool_name(pool));
|
applog(LOG_INFO, "Stratum extranonce subscribe for %s", get_pool_name(pool));
|
||||||
|
|
||||||
|
out:
|
||||||
|
json_decref(val);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2520,10 +2568,10 @@ bool restart_stratum(struct pool *pool)
|
|||||||
suspend_stratum(pool);
|
suspend_stratum(pool);
|
||||||
if (!initiate_stratum(pool))
|
if (!initiate_stratum(pool))
|
||||||
return false;
|
return false;
|
||||||
if (!auth_stratum(pool))
|
|
||||||
return false;
|
|
||||||
if (opt_extranonce_subscribe && !subscribe_extranonce(pool))
|
if (opt_extranonce_subscribe && !subscribe_extranonce(pool))
|
||||||
return false;
|
return false;
|
||||||
|
if (!auth_stratum(pool))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user