Browse Source

Send and parse node request with passthrough message

master
Con Kolivas 10 years ago
parent
commit
e96f1d60e2
  1. 13
      src/generator.c
  2. 11
      src/stratifier.c

13
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);

11
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;

Loading…
Cancel
Save