From e96f1d60e23dec450253c288e70749fcdd7b6735 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 16 Jun 2015 17:55:53 +1000 Subject: [PATCH] Send and parse node request with passthrough message --- src/generator.c | 13 ++++++++----- src/stratifier.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/generator.c b/src/generator.c index 15d8971b..65ee3492 100644 --- a/src/generator.c +++ b/src/generator.c @@ -753,14 +753,14 @@ out: return ret; } -static bool passthrough_stratum(connsock_t *cs, proxy_instance_t *proxi) +static bool passthrough_stratum(connsock_t *cs, proxy_instance_t *proxi, const bool node) { json_t *req, *val = NULL, *res_val, *err_val; bool ret = false; - JSON_CPACK(req, "{s:s,s:[s]}", + JSON_CPACK(req, "{s:s,s:[sb]}", "method", "mining.passthrough", - "params", PACKAGE"/"VERSION); + "params", PACKAGE"/"VERSION, node); ret = send_json_msg(cs, req); json_decref(req); if (!ret) { @@ -1758,7 +1758,7 @@ static bool proxy_alive(ckpool_t *ckp, proxy_instance_t *proxi, connsock_t *cs, goto out; } if (ckp->passthrough) { - if (!passthrough_stratum(cs, proxi)) { + if (!passthrough_stratum(cs, proxi, ckp->node)) { LOGWARNING("Failed initial passthrough to %s:%s !", cs->url, cs->port); goto out; @@ -2718,9 +2718,12 @@ static int proxy_mode(ckpool_t *ckp, proc_instance_t *pi) si->cs.url, si->cs.port); ckp->btcdbackup = NULL; free(si); + ckp->node = false; } - } else + } else { LOGWARNING("No backup btcd specified in node mode! Will run as ordinary passthrough"); + ckp->node = false; + } } LOGWARNING("%s generator ready", ckp->name); diff --git a/src/stratifier.c b/src/stratifier.c index 2d8f006a..65fe62e3 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -4817,14 +4817,21 @@ static void parse_method(ckpool_t *ckp, sdata_t *sdata, stratum_instance_t *clie } if (unlikely(cmdmatch(method, "mining.passthrough"))) { + json_t *nodeval = json_array_get(params_val, 1); char buf[256]; + bool node; + if (nodeval) + node = json_is_true(nodeval); + else + node = false; /* We need to inform the connector process that this client * is a passthrough and to manage its messages accordingly. No * data from this client id should ever come back to this * stratifier after this so drop the client in the stratifier. */ - LOGNOTICE("Adding passthrough client %"PRId64" %s", client_id, client->address); - snprintf(buf, 255, "passthrough=%"PRId64, client_id); + LOGNOTICE("Adding %spassthrough client %"PRId64" %s", node ? "node " : "", + client_id, client->address); + snprintf(buf, 255, "%s=%"PRId64, node ? "node" : "passthrough", client_id); send_proc(ckp->connector, buf); drop_client(ckp, sdata, client_id); return;