Browse Source

Make displayed stats based on round shares

master
Con Kolivas 11 years ago
parent
commit
10a4b36f31
  1. 64
      src/stratifier.c

64
src/stratifier.c

@ -61,6 +61,8 @@ struct pool_stats {
int64_t accounted_diff_shares; int64_t accounted_diff_shares;
int64_t unaccounted_rejects; int64_t unaccounted_rejects;
int64_t accounted_rejects; int64_t accounted_rejects;
int64_t pplns_shares;
int64_t round_shares;
/* Diff shares per second for 1/5/15... minute rolling averages */ /* Diff shares per second for 1/5/15... minute rolling averages */
double dsps1; double dsps1;
@ -802,7 +804,7 @@ static void log_pplns(const char *logdir, user_instance_t *instance)
LOGERR("Failed to fopen %s", fnametmp); LOGERR("Failed to fopen %s", fnametmp);
return; return;
} }
fprintf(fp, "%lu", instance->pplns_shares); fprintf(fp, "%lu,%ld,%ld", instance->pplns_shares, instance->diff_accepted, instance->diff_rejected);
fclose(fp); fclose(fp);
snprintf(fname, 511, "%s/%s.pplns", logdir, instance->username); snprintf(fname, 511, "%s/%s.pplns", logdir, instance->username);
if (rename(fnametmp, fname)) if (rename(fnametmp, fname))
@ -821,7 +823,7 @@ static void stratum_broadcast_message(const char *msg)
/* FIXME: This is all a simple workaround till we use a proper database. */ /* FIXME: This is all a simple workaround till we use a proper database. */
static void block_solve(ckpool_t *ckp) static void block_solve(ckpool_t *ckp)
{ {
double total = 0, retain = 0, window; double round, total = 0, retain = 0, window;
user_instance_t *instance, *tmp; user_instance_t *instance, *tmp;
char *msg; char *msg;
@ -831,33 +833,44 @@ static void block_solve(ckpool_t *ckp)
LOGWARNING("Block solve user summary"); LOGWARNING("Block solve user summary");
ck_rlock(&instance_lock); mutex_lock(&stats_lock);
/* Work out the total first */ total = stats.pplns_shares;
HASH_ITER(hh, user_instances, instance, tmp) round = stats.round_shares;
total += instance->pplns_shares; mutex_unlock(&stats_lock);
if (unlikely(total == 0.0))
total = 1;
ck_rlock(&instance_lock);
/* What proportion of shares should each user retain */ /* What proportion of shares should each user retain */
if (total > window) if (total > window)
retain = (total - window) / total; retain = (total - window) / total;
HASH_ITER(hh, user_instances, instance, tmp) { HASH_ITER(hh, user_instances, instance, tmp) {
double residual, shares; double residual, shares, percentage;
shares = instance->pplns_shares; shares = instance->pplns_shares;
if (!shares) if (!shares)
continue; continue;
residual = shares * retain; residual = shares * retain;
LOGWARNING("User %s: Credited: %.0f Remaining: %.0f", instance->username, percentage = shares / total * 100;
shares, residual); LOGWARNING("User %s: Reward: %f %% Credited: %.0f Remaining: %.0f",
instance->username, percentage, shares, residual);
instance->pplns_shares = residual; instance->pplns_shares = residual;
instance->diff_accepted = instance->diff_rejected = 0;
log_pplns(ckp->logdir, instance); log_pplns(ckp->logdir, instance);
} }
ck_runlock(&instance_lock); ck_runlock(&instance_lock);
LOGWARNING("Total shares from all users: %.0f pplns window %.0f", total, window); LOGWARNING("Round shares: %.0f Total pplns: %.0f pplns window %.0f", round, total, window);
ASPRINTF(&msg, "Block solved by %s after %.0f shares!", ckp->name, total); ASPRINTF(&msg, "Block solved by %s after %.0f shares!", ckp->name, round);
stratum_broadcast_message(msg); stratum_broadcast_message(msg);
free(msg); free(msg);
mutex_lock(&stats_lock);
stats.round_shares = 0;
stats.pplns_shares *= retain;
mutex_unlock(&stats_lock);
} }
static int stratum_loop(ckpool_t *ckp, proc_instance_t *pi) static int stratum_loop(ckpool_t *ckp, proc_instance_t *pi)
@ -1855,6 +1868,7 @@ static void *statsupdate(void *arg)
double sps1, sps5, sps15, sps60; double sps1, sps5, sps15, sps60;
user_instance_t *instance, *tmp; user_instance_t *instance, *tmp;
double ghs, tdiff, bias; double ghs, tdiff, bias;
int64_t pplns_shares;
char fname[512] = {}; char fname[512] = {};
tv_t now, diff; tv_t now, diff;
FILE *fp; FILE *fp;
@ -1897,6 +1911,8 @@ static void *statsupdate(void *arg)
if (unlikely(!fp)) if (unlikely(!fp))
LOGERR("Failed to fopen %s", fname); LOGERR("Failed to fopen %s", fname);
pplns_shares = stats.pplns_shares + 1;
snprintf(logout, 511, "runtime: %lus Live clients: %d Dead clients: %d " snprintf(logout, 511, "runtime: %lus Live clients: %d Dead clients: %d "
"Reusable clients: %d Reused clients: %d", "Reusable clients: %d Reused clients: %d",
diff.tv_sec, stats.live_clients, stats.dead_clients, diff.tv_sec, stats.live_clients, stats.dead_clients,
@ -1907,8 +1923,8 @@ static void *statsupdate(void *arg)
suffix1, suffix5, suffix15, suffix60, suffix360, suffix1440); suffix1, suffix5, suffix15, suffix60, suffix360, suffix1440);
LOGNOTICE("Pool %s", logout); LOGNOTICE("Pool %s", logout);
fprintf(fp, "%s\n", logout); fprintf(fp, "%s\n", logout);
snprintf(logout, 511, "shares A: %ld R: %ld Absolute per second: (1m):%.1f (5m):%.1f (15m):%.1f (1h):%.1f", snprintf(logout, 511, "round shares: %ld Absolute per second: (1m):%.1f (5m):%.1f (15m):%.1f (1h):%.1f",
stats.accounted_diff_shares, stats.accounted_rejects, sps1, sps5, sps15, sps60); stats.round_shares, sps1, sps5, sps15, sps60);
LOGNOTICE("Pool %s", logout); LOGNOTICE("Pool %s", logout);
fprintf(fp, "%s\n", logout); fprintf(fp, "%s\n", logout);
fclose(fp); fclose(fp);
@ -1916,6 +1932,7 @@ static void *statsupdate(void *arg)
ck_rlock(&instance_lock); ck_rlock(&instance_lock);
HASH_ITER(hh, user_instances, instance, tmp) { HASH_ITER(hh, user_instances, instance, tmp) {
bool idle = false; bool idle = false;
double reward;
if (now.tv_sec - instance->last_share.tv_sec > 60) { if (now.tv_sec - instance->last_share.tv_sec > 60) {
idle = true; idle = true;
@ -1939,9 +1956,12 @@ static void *statsupdate(void *arg)
suffix_string(ghs, suffix360, 16, 0); suffix_string(ghs, suffix360, 16, 0);
ghs = instance->dsps1440 * nonces; ghs = instance->dsps1440 * nonces;
suffix_string(ghs, suffix1440, 16, 0); suffix_string(ghs, suffix1440, 16, 0);
snprintf(logout, 511, "A: %ld R: %ld Shares: %lu "
reward = 25 * instance->pplns_shares;
reward /= pplns_shares;
snprintf(logout, 511, "A: %ld R: %ld Est Reward: %f "
"Hashrate: (1m):%s (5m):%s (15m):%s (1h):%s (6h):%s (1d):%s", "Hashrate: (1m):%s (5m):%s (15m):%s (1h):%s (6h):%s (1d):%s",
instance->diff_accepted, instance->diff_rejected, instance->pplns_shares, instance->diff_accepted, instance->diff_rejected, reward,
suffix1, suffix5, suffix15, suffix60, suffix360, suffix1440); suffix1, suffix5, suffix15, suffix60, suffix360, suffix1440);
/* Only display the status of connected users to the /* Only display the status of connected users to the
@ -1969,6 +1989,8 @@ static void *statsupdate(void *arg)
mutex_lock(&stats_lock); mutex_lock(&stats_lock);
stats.accounted_shares += stats.unaccounted_shares; stats.accounted_shares += stats.unaccounted_shares;
stats.accounted_diff_shares += stats.unaccounted_diff_shares; stats.accounted_diff_shares += stats.unaccounted_diff_shares;
stats.round_shares += stats.unaccounted_diff_shares;
stats.pplns_shares += stats.unaccounted_diff_shares;
stats.accounted_rejects += stats.unaccounted_rejects; stats.accounted_rejects += stats.unaccounted_rejects;
decay_time(&stats.sps1, stats.unaccounted_shares, 15, 60); decay_time(&stats.sps1, stats.unaccounted_shares, 15, 60);
@ -2002,10 +2024,12 @@ static void load_users(ckpool_t *ckp)
if (!dp) if (!dp)
quit(1, "Failed to open logdir %s!", ckp->logdir); quit(1, "Failed to open logdir %s!", ckp->logdir);
while ((ep = readdir(dp))) { while ((ep = readdir(dp))) {
int64_t diff_accepted, diff_rejected = 0;
user_instance_t *instance; user_instance_t *instance;
uint64_t pplns_shares; uint64_t pplns_shares;
char fname[512] = {}; char fname[512] = {};
char *period; char *period;
int results;
FILE *fp; FILE *fp;
if (strlen(ep->d_name) < 7) if (strlen(ep->d_name) < 7)
@ -2019,8 +2043,11 @@ static void load_users(ckpool_t *ckp)
LOGERR("Failed to open pplns logfile %s!", fname); LOGERR("Failed to open pplns logfile %s!", fname);
continue; continue;
} }
if (fscanf(fp, "%lu", &pplns_shares) < 1) results = fscanf(fp, "%lu,%ld,%ld", &pplns_shares, &diff_accepted, &diff_rejected);
if (results < 1)
continue; continue;
if (results == 1)
diff_accepted = pplns_shares;
if (!pplns_shares) if (!pplns_shares)
continue; continue;
@ -2030,7 +2057,10 @@ static void load_users(ckpool_t *ckp)
period = strstr(instance->username, "."); period = strstr(instance->username, ".");
*period = '\0'; *period = '\0';
instance->pplns_shares = pplns_shares; instance->pplns_shares = pplns_shares;
stats.accounted_diff_shares += pplns_shares; stats.pplns_shares += pplns_shares;
instance->diff_accepted = diff_accepted;
instance->diff_rejected = diff_rejected;
stats.round_shares += diff_accepted;
ck_wlock(&instance_lock); ck_wlock(&instance_lock);
HASH_ADD_STR(user_instances, username, instance); HASH_ADD_STR(user_instances, username, instance);

Loading…
Cancel
Save