|
|
|
@ -1878,7 +1878,9 @@ bool parse_method(struct pool *pool, char *s)
@@ -1878,7 +1878,9 @@ bool parse_method(struct pool *pool, char *s)
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
sprintf(s, "{\"id\": %d, \"method\": \"mining.extranonce.subscribe\", \"params\": []}", |
|
|
|
@ -1887,8 +1889,54 @@ bool subscribe_extranonce(struct pool *pool)
@@ -1887,8 +1889,54 @@ bool subscribe_extranonce(struct pool *pool)
|
|
|
|
|
if (!stratum_send(pool, s, strlen(s))) |
|
|
|
|
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; |
|
|
|
|
applog(LOG_INFO, "Stratum extranonce subscribe for %s", get_pool_name(pool)); |
|
|
|
|
|
|
|
|
|
out: |
|
|
|
|
json_decref(val); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2520,10 +2568,10 @@ bool restart_stratum(struct pool *pool)
@@ -2520,10 +2568,10 @@ bool restart_stratum(struct pool *pool)
|
|
|
|
|
suspend_stratum(pool); |
|
|
|
|
if (!initiate_stratum(pool)) |
|
|
|
|
return false; |
|
|
|
|
if (!auth_stratum(pool)) |
|
|
|
|
return false; |
|
|
|
|
if (opt_extranonce_subscribe && !subscribe_extranonce(pool)) |
|
|
|
|
return false; |
|
|
|
|
if (!auth_stratum(pool)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|