Browse Source

Implement a stratum reconnect function

master
Con Kolivas 10 years ago
parent
commit
5532de0f1b
  1. 8
      src/ckpool.c
  2. 13
      src/stratifier.c

8
src/ckpool.c

@ -288,12 +288,16 @@ retry:
LOGWARNING("Failed to send_procmsg to connector"); LOGWARNING("Failed to send_procmsg to connector");
} else if (cmdmatch(buf, "accept")) { } else if (cmdmatch(buf, "accept")) {
LOGWARNING("Listener received accept message, accepting clients"); LOGWARNING("Listener received accept message, accepting clients");
send_unix_msg(sockd, "accepting");
send_procmsg(ckp->connector, "accept"); send_procmsg(ckp->connector, "accept");
send_unix_msg(sockd, "accepting");
} else if (cmdmatch(buf, "reject")) { } else if (cmdmatch(buf, "reject")) {
LOGWARNING("Listener received reject message, rejecting clients"); LOGWARNING("Listener received reject message, rejecting clients");
send_unix_msg(sockd, "rejecting");
send_procmsg(ckp->connector, "reject"); send_procmsg(ckp->connector, "reject");
send_unix_msg(sockd, "rejecting");
} else if (cmdmatch(buf, "reconnect")) {
LOGWARNING("Listener received request to send reconnect to clients");
send_procmsg(ckp->stratifier, "reconnect");
send_unix_msg(sockd, "reconnecting");
} else if (cmdmatch(buf, "restart")) { } else if (cmdmatch(buf, "restart")) {
LOGWARNING("Listener received restart message, attempting handover"); LOGWARNING("Listener received restart message, attempting handover");
send_unix_msg(sockd, "restarting"); send_unix_msg(sockd, "restarting");

13
src/stratifier.c

@ -1138,6 +1138,17 @@ static void stratum_broadcast_message(const char *msg)
stratum_broadcast(json_msg); stratum_broadcast(json_msg);
} }
/* Send a generic reconnect to all clients without parameters to make them
* reconnect to the same server. */
static void reconnect_clients(void)
{
json_t *json_msg;
JSON_CPACK(json_msg, "{sosss[]}", "id", json_null(), "method", "client.reconnect",
"params");
stratum_broadcast(json_msg);
}
static void block_solve(ckpool_t *ckp) static void block_solve(ckpool_t *ckp)
{ {
char cdfield[64]; char cdfield[64];
@ -1281,6 +1292,8 @@ retry:
drop_allclients(ckp); drop_allclients(ckp);
} else if (cmdmatch(buf, "block")) { } else if (cmdmatch(buf, "block")) {
block_solve(ckp); block_solve(ckp);
} else if (cmdmatch(buf, "reconnect")) {
reconnect_clients();
} else if (cmdmatch(buf, "loglevel")) { } else if (cmdmatch(buf, "loglevel")) {
sscanf(buf, "loglevel=%d", &ckp->loglevel); sscanf(buf, "loglevel=%d", &ckp->loglevel);
} else { } else {

Loading…
Cancel
Save