diff --git a/src/connector.c b/src/connector.c index 67d5ce9f..3f6beb89 100644 --- a/src/connector.c +++ b/src/connector.c @@ -1229,6 +1229,12 @@ retry: * so look for them first. */ if (likely(buf[0] == '{')) { process_client_msg(cdata, buf); + } else if (cmdmatch(buf, "upstream=")) { + char *msg = strdup(buf + 9); + + LOGDEBUG("Upstreaming %s", msg); + ckmsgq_add(cdata->upstream_sends, msg); + goto retry; } else if (cmdmatch(buf, "dropclient")) { client_instance_t *client; diff --git a/src/stratifier.c b/src/stratifier.c index c4bc8c68..6af87656 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -2299,7 +2299,7 @@ static void stratum_broadcast(sdata_t *sdata, json_t *val, const int msg_type) continue; } - if (client->node) + if (client->node || client->remote) continue; /* Test for clients that haven't authed in over a minute and drop them */ @@ -4435,6 +4435,15 @@ static double time_bias(const double tdiff, const double period) return 1.0 - 1.0 / exp(dexp); } +static void upstream_shares(ckpool_t *ckp, const char *workername, const int64_t diff) +{ + char buf[256]; + + sprintf(buf, "upstream={\"method\":\"shares\",\"workername\":\"%s\",\"diff\":%"PRId64"}\n", + workername, diff); + send_proc(ckp->connector, buf); +} + /* Needs to be entered with client holding a ref count. */ static void add_submit(ckpool_t *ckp, stratum_instance_t *client, const double diff, const bool valid, const bool submit) @@ -4458,6 +4467,9 @@ static void add_submit(ckpool_t *ckp, stratum_instance_t *client, const double d if (valid) { worker->shares += diff; user->shares += diff; + /* Send shares to the upstream pool in trusted remote node */ + if (ckp->remote) + upstream_shares(ckp, worker->workername, diff); } else if (!submit) return; @@ -5447,6 +5459,7 @@ static void parse_remote_shares(sdata_t *sdata, json_t *val, const char *buf) return; } user = user_by_workername(sdata, workername); + user->authorised = true; worker = get_worker(sdata, user, workername); mutex_lock(&sdata->stats_lock); @@ -5462,7 +5475,7 @@ static void parse_remote_shares(sdata_t *sdata, json_t *val, const char *buf) copy_tv(&worker->last_share, &now_t); worker->idle = false; - LOGDEBUG("Added %"PRId64" shares to worker %s", diff, workername); + LOGINFO("Added %"PRId64" remote shares to worker %s", diff, workername); } static void parse_trusted_msg(sdata_t *sdata, json_t *val, const char *buf)