Browse Source

Upstream shares and process them accordingly in trusted mode

master
Con Kolivas 9 years ago
parent
commit
6947a4642a
  1. 6
      src/connector.c
  2. 17
      src/stratifier.c

6
src/connector.c

@ -1229,6 +1229,12 @@ retry:
* so look for them first. */ * so look for them first. */
if (likely(buf[0] == '{')) { if (likely(buf[0] == '{')) {
process_client_msg(cdata, buf); 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")) { } else if (cmdmatch(buf, "dropclient")) {
client_instance_t *client; client_instance_t *client;

17
src/stratifier.c

@ -2299,7 +2299,7 @@ static void stratum_broadcast(sdata_t *sdata, json_t *val, const int msg_type)
continue; continue;
} }
if (client->node) if (client->node || client->remote)
continue; continue;
/* Test for clients that haven't authed in over a minute and drop them */ /* 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); 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. */ /* 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, static void add_submit(ckpool_t *ckp, stratum_instance_t *client, const double diff, const bool valid,
const bool submit) const bool submit)
@ -4458,6 +4467,9 @@ static void add_submit(ckpool_t *ckp, stratum_instance_t *client, const double d
if (valid) { if (valid) {
worker->shares += diff; worker->shares += diff;
user->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) } else if (!submit)
return; return;
@ -5447,6 +5459,7 @@ static void parse_remote_shares(sdata_t *sdata, json_t *val, const char *buf)
return; return;
} }
user = user_by_workername(sdata, workername); user = user_by_workername(sdata, workername);
user->authorised = true;
worker = get_worker(sdata, user, workername); worker = get_worker(sdata, user, workername);
mutex_lock(&sdata->stats_lock); 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); copy_tv(&worker->last_share, &now_t);
worker->idle = false; 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) static void parse_trusted_msg(sdata_t *sdata, json_t *val, const char *buf)

Loading…
Cancel
Save