From b062a8e29a86c14ce6b2446eb5c2fc0d8b534357 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 26 Nov 2015 14:37:53 +1100 Subject: [PATCH] Add basic stats to console throbber line --- src/stratifier.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/stratifier.c b/src/stratifier.c index 61a41e24..6274e488 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -40,6 +40,7 @@ static const char *workpadding = "000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"; static const char *scriptsig_header = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff"; static uchar scriptsig_header_bin[41]; +static const double nonces = 4294967296; /* Add unaccounted shares when they arrive, remove them with each update of * rolling stats. */ @@ -693,10 +694,15 @@ static void _ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val, const char now_t = time(NULL); if (now_t != time_counter) { + pool_stats_t *stats = &sdata->stats; + char hashrate[16]; + /* Rate limit to 1 update per second */ time_counter = now_t; + suffix_string(stats->dsps1 * nonces, hashrate, 16, 0); ch = status_chars[(counter++) & 0x3]; - fprintf(stdout, "%c\r", ch); + fprintf(stdout, "\33[2K\r%c %sH/s %.1f SPS %d users %d workers", + ch, hashrate, stats->sps1, stats->users, stats->workers); fflush(stdout); } @@ -1591,8 +1597,6 @@ static user_instance_t *user_by_workername(sdata_t *sdata, const char *workernam static worker_instance_t *get_worker(sdata_t *sdata, user_instance_t *user, const char *workername); -static const double nonces = 4294967296; - static json_t *worker_stats(const worker_instance_t *worker) { char suffix1[16], suffix5[16], suffix60[16], suffix1440[16], suffix10080[16];