Browse Source

api: add best share diff and last share time

best share diff require --show-diff

shown in the "pool" command
master
Tanguy Pruvot 9 years ago
parent
commit
dec6dbed77
  1. 9
      api.cpp
  2. 3
      api/index.php
  3. 7
      ccminer.cpp
  4. 2
      miner.h

9
api.cpp

@ -203,6 +203,9 @@ static char *getpoolnfo(char *params) @@ -203,6 +203,9 @@ static char *getpoolnfo(char *params)
char nonce[128] = { 0 };
int pooln = params ? atoi(params) % num_pools : cur_pooln;
struct pool_infos *p = &pools[pooln];
uint32_t last_share = 0;
if (p->last_share_time)
last_share = (uint32_t) (time(NULL) - p->last_share_time);
*s = '\0';
@ -215,12 +218,12 @@ static char *getpoolnfo(char *params) @@ -215,12 +218,12 @@ static char *getpoolnfo(char *params)
}
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|",
"BEST=%.6f;N2SZ=%d;N2=%s;PING=%u;DISCO=%u;WAIT=%u;UPTIME=%u;LAST=%u|",
p->url, p->type & POOL_STRATUM ? p->user : "",
p->solved_count, p->accepted_count, p->rejected_count,
stratum.job.height, jobid, stratum_diff,
stratum.job.height, jobid, stratum_diff, p->best_share,
(int) stratum.xnonce2_size, nonce, stratum.answer_msec,
p->disconnects, p->wait_time, p->work_time);
p->disconnects, p->wait_time, p->work_time, last_share);
return s;
}

3
api/index.php

@ -47,6 +47,8 @@ function translateField($key) @@ -47,6 +47,8 @@ function translateField($key)
$intl['ACCMN'] = 'Accepted / mn';
$intl['REJ'] = 'Rejected';
$intl['SOLV'] = 'Solved';
$intl['BEST'] = 'Best share';
$intl['LAST'] = 'Last share';
$intl['DIFF'] = 'Difficulty';
$intl['NETKHS'] = 'Net Rate';
$intl['UPTIME'] = 'Miner up time';
@ -54,7 +56,6 @@ function translateField($key) @@ -54,7 +56,6 @@ function translateField($key)
$intl['THR'] = 'Throughput';
$intl['WAIT'] = 'Wait time';
$intl['H'] = 'Bloc height';
$intl['I'] = 'Intensity';
$intl['HWF'] = 'Failures';

7
ccminer.cpp

@ -659,13 +659,16 @@ static int share_result(int result, int pooln, double sharediff, const char *rea @@ -659,13 +659,16 @@ static int share_result(int result, int pooln, double sharediff, const char *rea
struct pool_infos *p = &pools[pooln];
pthread_mutex_lock(&stats_lock);
for (int i = 0; i < opt_n_threads; i++) {
hashrate += stats_get_speed(i, thr_hashrates[i]);
}
pthread_mutex_unlock(&stats_lock);
result ? p->accepted_count++ : p->rejected_count++;
pthread_mutex_unlock(&stats_lock);
p->last_share_time = time(NULL);
if (sharediff > p->best_share)
p->best_share = sharediff;
global_hashrate = llround(hashrate);

2
miner.h

@ -678,6 +678,8 @@ struct pool_infos { @@ -678,6 +678,8 @@ struct pool_infos {
uint32_t accepted_count;
uint32_t rejected_count;
uint32_t solved_count;
time_t last_share_time;
double best_share;
uint32_t disconnects;
};

Loading…
Cancel
Save