Browse Source

Differentiate generated authed users from unauthorised and don't do any stats on unauthed users

master
Con Kolivas 10 years ago
parent
commit
c7600f281b
  1. 21
      src/stratifier.c

21
src/stratifier.c

@ -180,6 +180,8 @@ struct user_instance {
double dsps1440; double dsps1440;
double dsps10080; double dsps10080;
tv_t last_share; tv_t last_share;
bool authorised; /* Has this username ever been authorised? */
time_t auth_time; time_t auth_time;
}; };
@ -2078,8 +2080,6 @@ static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, j
client->start_time = now.tv_sec; client->start_time = now.tv_sec;
strcpy(client->address, address); strcpy(client->address, address);
LOGNOTICE("Authorised client %ld worker %s as user %s", client->id, buf,
user_instance->username);
client->workername = strdup(buf); client->workername = strdup(buf);
if (CKP_STANDALONE(ckp)) if (CKP_STANDALONE(ckp))
ret = true; ret = true;
@ -2101,9 +2101,16 @@ static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, j
ret = true; ret = true;
} }
} }
client->authorised = ret; if (ret) {
if (client->authorised) client->authorised = ret;
user_instance->authorised = ret;
inc_worker(ckp, user_instance); inc_worker(ckp, user_instance);
LOGNOTICE("Authorised client %ld worker %s as user %s", client->id, buf,
user_instance->username);
} else {
LOGNOTICE("Client %ld worker %s failed to authorise as user %s", client->id, buf,
user_instance->username);
}
out: out:
return json_boolean(ret); return json_boolean(ret);
} }
@ -3401,6 +3408,9 @@ static void update_workerstats(ckpool_t *ckp, sdata_t *sdata)
worker_instance_t *worker; worker_instance_t *worker;
uint8_t cycle_mask; uint8_t cycle_mask;
if (!user->authorised)
continue;
/* Select users using a mask to return each user's stats once /* Select users using a mask to return each user's stats once
* every ~10 minutes */ * every ~10 minutes */
cycle_mask = user->id & 0x1f; cycle_mask = user->id & 0x1f;
@ -3572,6 +3582,9 @@ static void *statsupdate(void *arg)
worker_instance_t *worker; worker_instance_t *worker;
bool idle = false; bool idle = false;
if (!instance->authorised)
continue;
/* Decay times per worker */ /* Decay times per worker */
DL_FOREACH(instance->worker_instances, worker) { DL_FOREACH(instance->worker_instances, worker) {
per_tdiff = tvdiff(&now, &worker->last_share); per_tdiff = tvdiff(&now, &worker->last_share);

Loading…
Cancel
Save