Browse Source

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
master
Tanguy Pruvot 9 years ago
parent
commit
5a08c21355
  1. 14
      api.cpp
  2. 3
      api/index.php
  3. 11
      ccminer.cpp
  4. 1
      miner.h
  5. 11
      util.cpp

14
api.cpp

@ -8,7 +8,7 @@ @@ -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) @@ -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) @@ -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) @@ -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);

3
api/index.php

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<?php
/* ccminer API sample UI (API 1.5) */
/* ccminer API sample UI (API 1.7) */
$host = 'http://localhost/api/'; // 'http://'.$_SERVER['SERVER_NAME'].'/api/';
$configs = array(
@ -46,6 +46,7 @@ function translateField($key) @@ -46,6 +46,7 @@ function translateField($key)
$intl['ACC'] = 'Accepted shares';
$intl['ACCMN'] = 'Accepted / mn';
$intl['REJ'] = 'Rejected';
$intl['SOLV'] = 'Solved';
$intl['DIFF'] = 'Difficulty';
$intl['NETKHS'] = 'Net Rate';
$intl['UPTIME'] = 'Miner up time';

11
ccminer.cpp

@ -680,6 +680,7 @@ static int share_result(int result, int pooln, double sharediff, const char *rea @@ -680,6 +680,7 @@ static int share_result(int result, int pooln, double sharediff, const char *rea
(result ? CL_GRN YES : CL_RED BOO)
: (result ? "(" YES ")" : "(" BOO ")");
} else {
p->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) @@ -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;
}

1
miner.h

@ -678,6 +678,7 @@ struct pool_infos { @@ -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;
};

11
util.cpp

@ -842,8 +842,8 @@ void diff_to_target(uint32_t *target, double diff) @@ -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) @@ -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;
}

Loading…
Cancel
Save