|
|
|
@ -1363,23 +1363,29 @@ bool auth_stratum(struct pool *pool)
@@ -1363,23 +1363,29 @@ bool auth_stratum(struct pool *pool)
|
|
|
|
|
json_error_t err; |
|
|
|
|
bool ret = false; |
|
|
|
|
|
|
|
|
|
pool->stratum_notify = false; |
|
|
|
|
|
|
|
|
|
sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}", |
|
|
|
|
swork_id++, pool->rpc_user, pool->rpc_pass); |
|
|
|
|
|
|
|
|
|
if (!stratum_send(pool, s, strlen(s))) |
|
|
|
|
goto out; |
|
|
|
|
|
|
|
|
|
/* Parse all data in the queue and anything left should be auth */ |
|
|
|
|
/* Parse all data in the queue and break out should we run out of data
|
|
|
|
|
* or we have successfully parsed a notify message. */ |
|
|
|
|
while (42) { |
|
|
|
|
sret = recv_line(pool); |
|
|
|
|
if (!sret) |
|
|
|
|
goto out; |
|
|
|
|
if (parse_method(pool, sret)) |
|
|
|
|
if (parse_method(pool, sret)) { |
|
|
|
|
free(sret); |
|
|
|
|
else |
|
|
|
|
if (pool->stratum_notify) |
|
|
|
|
break; |
|
|
|
|
} else |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!pool->stratum_notify) { |
|
|
|
|
val = JSON_LOADS(sret, &err); |
|
|
|
|
free(sret); |
|
|
|
|
res_val = json_object_get(val, "result"); |
|
|
|
@ -1394,7 +1400,9 @@ bool auth_stratum(struct pool *pool)
@@ -1394,7 +1400,9 @@ bool auth_stratum(struct pool *pool)
|
|
|
|
|
ss = strdup("(unknown reason)"); |
|
|
|
|
applog(LOG_WARNING, "JSON stratum auth failed: %s", ss); |
|
|
|
|
free(ss); |
|
|
|
|
|
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
applog(LOG_WARNING, "Failed to auth stratum"); |
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|