Browse Source

Preauth workers for the first 10 minutes after a user first authorises

master
Con Kolivas 10 years ago
parent
commit
4d72f49061
  1. 11
      src/stratifier.c

11
src/stratifier.c

@ -180,6 +180,7 @@ struct user_instance {
double dsps1440; double dsps1440;
double dsps10080; double dsps10080;
tv_t last_share; tv_t last_share;
time_t auth_time;
}; };
/* Combined data from workers with the same workername */ /* Combined data from workers with the same workername */
@ -1953,6 +1954,8 @@ static int send_recv_auth(stratum_instance_t *client)
json_get_string(&secondaryuserid, val, "secondaryuserid"); json_get_string(&secondaryuserid, val, "secondaryuserid");
json_get_int(&worker->mindiff, val, "difficultydefault"); json_get_int(&worker->mindiff, val, "difficultydefault");
client->suggest_diff = worker->mindiff; client->suggest_diff = worker->mindiff;
if (!user_instance->auth_time)
user_instance->auth_time = time(NULL);
} }
if (secondaryuserid && (!safecmp(response, "ok.authorise") || if (secondaryuserid && (!safecmp(response, "ok.authorise") ||
!safecmp(response, "ok.addrauth"))) { !safecmp(response, "ok.addrauth"))) {
@ -2054,7 +2057,13 @@ static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, j
if (CKP_STANDALONE(ckp)) if (CKP_STANDALONE(ckp))
ret = true; ret = true;
else { else {
*errnum = send_recv_auth(client); /* Preauth workers for the first 10 minutes after the user is
* first authorised by ckdb to avoid floods of worker auths.
* *errnum is implied zero already so ret will be set true */
if (user_instance->auth_time && time(NULL) - user_instance->auth_time < 600)
queue_delayed_auth(client);
else
*errnum = send_recv_auth(client);
if (!*errnum) if (!*errnum)
ret = true; ret = true;
else if (*errnum < 0 && user_instance->secondaryuserid) { else if (*errnum < 0 && user_instance->secondaryuserid) {

Loading…
Cancel
Save