Browse Source

Implement rudimentary mining.reconnect support for stratum.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
783af8768b
  1. 27
      util.c

27
util.c

@ -850,6 +850,7 @@ bool extract_sockaddr(struct pool *pool, char *url)
pool->server = (struct sockaddr_in *)res->ai_addr; pool->server = (struct sockaddr_in *)res->ai_addr;
pool->sockaddr_url = strdup(url_address); pool->sockaddr_url = strdup(url_address);
return true; return true;
} }
@ -1096,6 +1097,27 @@ static bool parse_diff(struct pool *pool, json_t *val)
return true; return true;
} }
static bool parse_reconnect(struct pool *pool, json_t *val)
{
char *url;
url = (char *)json_string_value(json_array_get(val, 0));
if (!url)
return false;
if (!extract_sockaddr(pool, url))
return false;
pool->stratum_url = pool->sockaddr_url;
applog(LOG_NOTICE, "Reconnect requested from pool %d to %s", pool->pool_no, pool->stratum_url);
if (!initiate_stratum(pool) || !auth_stratum(pool))
return false;
return true;
}
bool parse_method(struct pool *pool, char *s) bool parse_method(struct pool *pool, char *s)
{ {
json_t *val = NULL, *method, *err_val, *params; json_t *val = NULL, *method, *err_val, *params;
@ -1147,6 +1169,11 @@ bool parse_method(struct pool *pool, char *s)
goto out; goto out;
} }
if (!strncasecmp(buf, "mining.reconnect", 16) && parse_reconnect(pool, params)) {
ret = true;
goto out;
}
out: out:
if (val) if (val)
json_decref(val); json_decref(val);

Loading…
Cancel
Save