From 5a08c21355d8dee5ca4b50207ea874e6ccb675e4 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Wed, 14 Oct 2015 20:20:16 +0200 Subject: [PATCH] diff: store solved blocs count, update the api Also show the real target diff on pools for the algos with a factor (lyra) require the --show-diff parameter, may be used as default in the final 1.7 --- api.cpp | 14 ++++++++------ api/index.php | 3 ++- ccminer.cpp | 11 +++++++++++ miner.h | 1 + util.cpp | 11 ++--------- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/api.cpp b/api.cpp index 9ad0c71..282f9d1 100644 --- a/api.cpp +++ b/api.cpp @@ -8,7 +8,7 @@ * Software Foundation; either version 2 of the License, or (at your option) * any later version. See COPYING for more details. */ -#define APIVERSION "1.6" +#define APIVERSION "1.7" #ifdef WIN32 # define _WINSOCK_DEPRECATED_NO_WARNINGS @@ -168,11 +168,13 @@ static char *getsummary(char *params) char algo[64]; *algo = '\0'; time_t ts = time(NULL); double accps, uptime = difftime(ts, startup); - uint32_t wait_time = 0, accepted_count = 0, rejected_count = 0; + uint32_t wait_time = 0, solved_count = 0; + uint32_t accepted_count = 0, rejected_count = 0; for (int p = 0; p < num_pools; p++) { wait_time += pools[p].wait_time; accepted_count += pools[p].accepted_count; rejected_count += pools[p].rejected_count; + solved_count += pools[p].solved_count; } accps = (60.0 * accepted_count) / (uptime ? uptime : 1.0); @@ -180,12 +182,12 @@ static char *getsummary(char *params) *buffer = '\0'; sprintf(buffer, "NAME=%s;VER=%s;API=%s;" - "ALGO=%s;GPUS=%d;KHS=%.2f;ACC=%d;REJ=%d;" + "ALGO=%s;GPUS=%d;KHS=%.2f;SOLV=%d;ACC=%d;REJ=%d;" "ACCMN=%.3f;DIFF=%.6f;NETKHS=%.0f;" "POOLS=%u;WAIT=%u;UPTIME=%.0f;TS=%u|", PACKAGE_NAME, PACKAGE_VERSION, APIVERSION, algo, active_gpus, (double)global_hashrate / 1000., - accepted_count, rejected_count, + solved_count, accepted_count, rejected_count, accps, net_diff > 1e-6 ? net_diff : stratum_diff, (double)net_hashrate / 1000., num_pools, wait_time, uptime, (uint32_t) ts); return buffer; @@ -212,10 +214,10 @@ static char *getpoolnfo(char *params) cbin2hex(&nonce[2], (const char*) stratum.job.xnonce2, stratum.xnonce2_size); } - snprintf(s, MYBUFSIZ, "URL=%s;USER=%s;ACC=%d;REJ=%d;H=%u;JOB=%s;DIFF=%.6f;" + snprintf(s, MYBUFSIZ, "URL=%s;USER=%s;SOLV=%d;ACC=%d;REJ=%d;H=%u;JOB=%s;DIFF=%.6f;" "N2SZ=%d;N2=%s;PING=%u;DISCO=%u;WAIT=%u;UPTIME=%u|", p->url, p->type & POOL_STRATUM ? p->user : "", - p->accepted_count, p->rejected_count, + p->solved_count, p->accepted_count, p->rejected_count, stratum.job.height, jobid, stratum_diff, (int) stratum.xnonce2_size, nonce, stratum.answer_msec, p->disconnects, p->wait_time, p->work_time); diff --git a/api/index.php b/api/index.php index 853b54e..5815970 100644 --- a/api/index.php +++ b/api/index.php @@ -1,5 +1,5 @@ solved_count++; flag = use_colors ? (result ? CL_GRN YAY : CL_RED BOO) : (result ? "(" YAY ")" : "(" BOO ")"); @@ -1384,6 +1385,16 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) default: work_set_target(work, sctx->job.diff / opt_difficulty); } + + if (stratum_diff != sctx->job.diff) { + char sdiff[32] = { 0 }; + // store for api stats + stratum_diff = sctx->job.diff; + if (opt_showdiff && work->targetdiff != stratum_diff) + snprintf(sdiff, 32, " (%.5f)", work->targetdiff); + applog(LOG_WARNING, "Stratum difficulty set to %g%s", stratum_diff, sdiff); + } + return true; } diff --git a/miner.h b/miner.h index 3096500..63964ad 100644 --- a/miner.h +++ b/miner.h @@ -678,6 +678,7 @@ struct pool_infos { uint32_t wait_time; uint32_t accepted_count; uint32_t rejected_count; + uint32_t solved_count; uint32_t disconnects; }; diff --git a/util.cpp b/util.cpp index dbee5c9..fb9e12d 100644 --- a/util.cpp +++ b/util.cpp @@ -842,8 +842,8 @@ void diff_to_target(uint32_t *target, double diff) // Only used by stratum pools void work_set_target(struct work* work, double diff) { - diff_to_target(work->target, diff); - work->targetdiff = diff; + diff_to_target(work->target, diff); + work->targetdiff = diff; } @@ -1528,13 +1528,6 @@ static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params) sctx->next_diff = diff; pthread_mutex_unlock(&stratum_work_lock); - /* store for api stats */ - if (diff != stratum_diff) { - stratum_diff = diff; - applog(LOG_WARNING, "Stratum difficulty set to %g", diff); - g_work_time = 0; - } - return true; }