|
|
@ -195,6 +195,7 @@ struct user_instance { |
|
|
|
|
|
|
|
|
|
|
|
tv_t last_share; |
|
|
|
tv_t last_share; |
|
|
|
time_t last_stats; |
|
|
|
time_t last_stats; |
|
|
|
|
|
|
|
time_t start_time; |
|
|
|
|
|
|
|
|
|
|
|
double dsps1; |
|
|
|
double dsps1; |
|
|
|
double dsps5; |
|
|
|
double dsps5; |
|
|
@ -1110,9 +1111,13 @@ static user_instance_t *authorise_user(const char *workername) |
|
|
|
ck_ilock(&instance_lock); |
|
|
|
ck_ilock(&instance_lock); |
|
|
|
HASH_FIND_STR(user_instances, username, instance); |
|
|
|
HASH_FIND_STR(user_instances, username, instance); |
|
|
|
if (!instance) { |
|
|
|
if (!instance) { |
|
|
|
|
|
|
|
ts_t now; |
|
|
|
|
|
|
|
|
|
|
|
/* New user instance */ |
|
|
|
/* New user instance */ |
|
|
|
instance = ckzalloc(sizeof(user_instance_t)); |
|
|
|
instance = ckzalloc(sizeof(user_instance_t)); |
|
|
|
strcpy(instance->username, username); |
|
|
|
strcpy(instance->username, username); |
|
|
|
|
|
|
|
ts_realtime(&now); |
|
|
|
|
|
|
|
instance->start_time = now.tv_sec; |
|
|
|
|
|
|
|
|
|
|
|
ck_ulock(&instance_lock); |
|
|
|
ck_ulock(&instance_lock); |
|
|
|
instance->id = user_instance_id++; |
|
|
|
instance->id = user_instance_id++; |
|
|
@ -2020,16 +2025,19 @@ static void update_userstats(ckpool_t *ckp) |
|
|
|
ck_rlock(&instance_lock); |
|
|
|
ck_rlock(&instance_lock); |
|
|
|
HASH_ITER(hh, user_instances, instance, tmp) { |
|
|
|
HASH_ITER(hh, user_instances, instance, tmp) { |
|
|
|
double ghs1, ghs5, ghs60, ghs1440; |
|
|
|
double ghs1, ghs5, ghs60, ghs1440; |
|
|
|
|
|
|
|
int elapsed; |
|
|
|
|
|
|
|
|
|
|
|
if (instance->last_stats > now_t - 600) |
|
|
|
if (instance->last_stats > now_t - 600) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
elapsed = now_t - instance->start_time; |
|
|
|
instance->last_stats = now_t; |
|
|
|
instance->last_stats = now_t; |
|
|
|
ghs1 = instance->dsps1 * nonces; |
|
|
|
ghs1 = instance->dsps1 * nonces; |
|
|
|
ghs5 = instance->dsps5 * nonces; |
|
|
|
ghs5 = instance->dsps5 * nonces; |
|
|
|
ghs60 = instance->dsps60 * nonces; |
|
|
|
ghs60 = instance->dsps60 * nonces; |
|
|
|
ghs1440 = instance->dsps1440 * nonces; |
|
|
|
ghs1440 = instance->dsps1440 * nonces; |
|
|
|
val = json_pack("{ss,ss,sf,sf,sf,sf,ss,ss,ss,ss}", |
|
|
|
val = json_pack("{ss,si,ss,sf,sf,sf,sf,ss,ss,ss,ss}", |
|
|
|
"poolinstance", ckp->name, |
|
|
|
"poolinstance", ckp->name, |
|
|
|
|
|
|
|
"elapsed", elapsed, |
|
|
|
"username", instance->username, |
|
|
|
"username", instance->username, |
|
|
|
"hashrate", ghs1, |
|
|
|
"hashrate", ghs1, |
|
|
|
"hashrate5m", ghs5, |
|
|
|
"hashrate5m", ghs5, |
|
|
@ -2196,8 +2204,9 @@ static void *statsupdate(void *arg) |
|
|
|
|
|
|
|
|
|
|
|
ts_realtime(&ts_now); |
|
|
|
ts_realtime(&ts_now); |
|
|
|
sprintf(cdfield, "%lu,%lu", ts_now.tv_sec, ts_now.tv_nsec); |
|
|
|
sprintf(cdfield, "%lu,%lu", ts_now.tv_sec, ts_now.tv_nsec); |
|
|
|
val = json_pack("{ss,si,si,sf,sf,sf,sf,ss,ss,ss,ss}", |
|
|
|
val = json_pack("{ss,si,si,si,sf,sf,sf,sf,ss,ss,ss,ss}", |
|
|
|
"poolinstance", ckp->name, |
|
|
|
"poolinstance", ckp->name, |
|
|
|
|
|
|
|
"elapsed", diff.tv_sec, |
|
|
|
"users", stats.users, |
|
|
|
"users", stats.users, |
|
|
|
"workers", stats.workers, |
|
|
|
"workers", stats.workers, |
|
|
|
"hashrate", ghs1, |
|
|
|
"hashrate", ghs1, |
|
|
|