Permalink
Browse files

Implement rudimentary mining.reconnect support for stratum.

  • Loading branch information...
ckolivas committed Oct 10, 2012
1 parent 974f65c commit 783af8768b595613ee5e4aabfefde24c0830e71a
Showing with 27 additions and 0 deletions.
  1. +27 −0 util.c
View
27 util.c
@@ -850,6 +850,7 @@ bool extract_sockaddr(struct pool *pool, char *url)
pool->server = (struct sockaddr_in *)res->ai_addr;
pool->sockaddr_url = strdup(url_address);
+
return true;
}
@@ -1096,6 +1097,27 @@ static bool parse_diff(struct pool *pool, json_t *val)
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)
{
json_t *val = NULL, *method, *err_val, *params;
@@ -1147,6 +1169,11 @@ bool parse_method(struct pool *pool, char *s)
goto out;
}
+ if (!strncasecmp(buf, "mining.reconnect", 16) && parse_reconnect(pool, params)) {
+ ret = true;
+ goto out;
+ }
+
out:
if (val)
json_decref(val);

0 comments on commit 783af87

Please sign in to comment.