Browse Source

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

master
Con Kolivas 10 years ago
parent
commit
a90b1fd024
  1. 9
      src/stratifier.c

9
src/stratifier.c

@ -180,6 +180,7 @@ struct user_instance {
double dsps1440;
double dsps10080;
tv_t last_share;
time_t auth_time;
};
/* Combined data from workers with the same workername */
@ -1981,6 +1982,8 @@ static int send_recv_auth(stratum_instance_t *client)
json_get_string(&secondaryuserid, val, "secondaryuserid");
json_get_int(&worker->mindiff, val, "difficultydefault");
client->suggest_diff = worker->mindiff;
if (!user_instance->auth_time)
user_instance->auth_time = time(NULL);
}
if (secondaryuserid && (!safecmp(response, "ok.authorise") ||
!safecmp(response, "ok.addrauth"))) {
@ -2082,6 +2085,12 @@ static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, j
if (CKP_STANDALONE(ckp))
ret = true;
else {
/* 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)
ret = true;

Loading…
Cancel
Save