Browse Source

Rename user instance user in generate_user for clarity

master
Con Kolivas 10 years ago
parent
commit
ad622680cb
  1. 30
      src/stratifier.c

30
src/stratifier.c

@ -2130,8 +2130,8 @@ static user_instance_t *generate_user(ckpool_t *ckp, stratum_instance_t *client,
char *base_username = strdupa(workername), *username; char *base_username = strdupa(workername), *username;
bool new_instance = false, new_worker = false; bool new_instance = false, new_worker = false;
sdata_t *sdata = ckp->data; sdata_t *sdata = ckp->data;
user_instance_t *instance;
stratum_instance_t *tmp; stratum_instance_t *tmp;
user_instance_t *user;
int len; int len;
username = strsep(&base_username, "._"); username = strsep(&base_username, "._");
@ -2142,16 +2142,16 @@ static user_instance_t *generate_user(ckpool_t *ckp, stratum_instance_t *client,
username[127] = '\0'; username[127] = '\0';
ck_wlock(&sdata->instance_lock); ck_wlock(&sdata->instance_lock);
HASH_FIND_STR(sdata->user_instances, username, instance); HASH_FIND_STR(sdata->user_instances, username, user);
if (!instance) { if (!user) {
/* New user instance. Secondary user id will be NULL */ /* New user instance. Secondary user id will be NULL */
instance = ckzalloc(sizeof(user_instance_t)); user = ckzalloc(sizeof(user_instance_t));
strcpy(instance->username, username); strcpy(user->username, username);
new_instance = true; new_instance = true;
instance->id = sdata->user_instance_id++; user->id = sdata->user_instance_id++;
HASH_ADD_STR(sdata->user_instances, username, instance); HASH_ADD_STR(sdata->user_instances, username, user);
} }
DL_FOREACH(instance->instances, tmp) { DL_FOREACH(user->instances, tmp) {
if (!safecmp(workername, tmp->workername)) { if (!safecmp(workername, tmp->workername)) {
client->worker_instance = tmp->worker_instance; client->worker_instance = tmp->worker_instance;
break; break;
@ -2163,29 +2163,29 @@ static user_instance_t *generate_user(ckpool_t *ckp, stratum_instance_t *client,
worker_instance_t *worker = ckzalloc(sizeof(worker_instance_t)); worker_instance_t *worker = ckzalloc(sizeof(worker_instance_t));
worker->workername = strdup(workername); worker->workername = strdup(workername);
worker->instance = instance; worker->instance = user;
DL_APPEND(instance->worker_instances, worker); DL_APPEND(user->worker_instances, worker);
new_worker = true; new_worker = true;
worker->start_time = time(NULL); worker->start_time = time(NULL);
client->worker_instance = worker; client->worker_instance = worker;
} }
DL_APPEND(instance->instances, client); DL_APPEND(user->instances, client);
ck_wunlock(&sdata->instance_lock); ck_wunlock(&sdata->instance_lock);
if (CKP_STANDALONE(ckp) && new_instance) if (CKP_STANDALONE(ckp) && new_instance)
read_userstats(ckp, instance); read_userstats(ckp, user);
if (CKP_STANDALONE(ckp) && new_worker) if (CKP_STANDALONE(ckp) && new_worker)
read_workerstats(ckp, client->worker_instance); read_workerstats(ckp, client->worker_instance);
if (new_instance && !ckp->proxy) { if (new_instance && !ckp->proxy) {
/* Is this a btc address based username? */ /* Is this a btc address based username? */
if (len > 26 && len < 35) if (len > 26 && len < 35)
instance->btcaddress = test_address(ckp, username); user->btcaddress = test_address(ckp, username);
LOGNOTICE("Added new user %s%s", username, instance->btcaddress ? LOGNOTICE("Added new user %s%s", username, user->btcaddress ?
" as address based registration" : ""); " as address based registration" : "");
} }
return instance; return user;
} }
/* Send this to the database and parse the response to authorise a user /* Send this to the database and parse the response to authorise a user

Loading…
Cancel
Save