Permalink
Browse files

diff: show share diff and solved blocs + api

(require the --show-diff parameter)
  • Loading branch information...
1 parent f7c584d commit fb137363702141114c45c3e20a5aecb4c69cd919 @tpruvot committed Dec 28, 2015
Showing with 38 additions and 14 deletions.
  1. +2 −1 NEWS
  2. +4 −3 api.c
  3. +32 −10 cpu-miner.c
View
@@ -8,6 +8,7 @@ Version 1.2 (Tanguy Pruvot)
- Add Bastion algo
- Add Yescrypt and scrypt-jane algos
- Compute and show network diff in pools too
+- Compute Shares diff and count solved blocks
- Checkup on arm, tested ok on Tegra K1 (CyanogenMod 12.1)
version 1.1 (Tanguy Pruvot)
@@ -46,7 +47,7 @@ Version 1.0.8 (Tanguy Pruvot)
Version 1.0.7 (Tanguy Pruvot)
- Add NIST5 and QUBIT algos
-- Show current stratum bloc height
+- Show current stratum block height
- Fix wallet solo mining
Version 1.0.6 (Tanguy Pruvot)
View
@@ -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.0"
+#define APIVERSION "1.1"
#ifdef WIN32
# define _WINSOCK_DEPRECATED_NO_WARNINGS
@@ -96,6 +96,7 @@ extern char *opt_api_allow;
extern int opt_api_listen; /* port */
extern int opt_api_remote;
extern uint64_t global_hashrate;
+extern uint32_t solved_count;
extern uint32_t accepted_count;
extern uint32_t rejected_count;
@@ -148,12 +149,12 @@ static char *getsummary(char *params)
*buffer = '\0';
sprintf(buffer, "NAME=%s;VER=%s;API=%s;"
- "ALGO=%s;CPUS=%d;KHS=%.2f;ACC=%d;REJ=%d;"
+ "ALGO=%s;CPUS=%d;KHS=%.2f;SOLV=%d;ACC=%d;REJ=%d;"
"ACCMN=%.3f;DIFF=%.6f;TEMP=%.1f;FAN=%d;FREQ=%d;"
"UPTIME=%.0f;TS=%u|",
PACKAGE_NAME, PACKAGE_VERSION, APIVERSION,
algo, opt_n_threads, (double)global_hashrate / 1000.0,
- accepted_count, rejected_count, accps, net_diff > 0. ? net_diff : stratum_diff,
+ solved_count, accepted_count, rejected_count, accps, net_diff > 0. ? net_diff : stratum_diff,
cpu.cpu_temp, cpu.cpu_fan, cpu.cpu_clock,
uptime, (uint32_t) ts);
return buffer;
View
@@ -222,6 +222,7 @@ pthread_mutex_t applog_lock;
pthread_mutex_t stats_lock;
uint32_t zr5_pok = 0;
+uint32_t solved_count = 0L;
uint32_t accepted_count = 0L;
uint32_t rejected_count = 0L;
double *thr_hashrates;
@@ -324,7 +325,8 @@ Options:\n\
-q, --quiet disable per-thread hashmeter output\n\
--no-color disable colored output\n\
-D, --debug enable debug output\n\
- -P, --protocol-dump verbose dump of protocol-level activities\n"
+ -P, --protocol-dump verbose dump of protocol-level activities\n\
+ --show-diff display submitted block and net difficulty\n"
#ifdef HAVE_SYSLOG_H
"\
-S, --syslog use system log for output messages\n"
@@ -921,11 +923,17 @@ static bool gbt_work_decode(const json_t *val, struct work *work)
return rc;
}
+#define YES "yes!"
+#define YAY "yay!!!"
+#define BOO "booooo"
+
static int share_result(int result, struct work *work, const char *reason)
{
+ const char *flag;
+ char suppl[32] = { 0 };
char s[345];
- const char *sres;
double hashrate;
+ double sharediff = work ? work->sharediff : stratum.sharediff;
int i;
hashrate = 0.;
@@ -937,10 +945,21 @@ static int share_result(int result, struct work *work, const char *reason)
global_hashrate = (uint64_t) hashrate;
- if (use_colors)
- sres = (result ? CL_GRN "yes!" : CL_RED "nooooo");
- else
- sres = (result ? "(yes!!!)" : "(nooooo)");
+ if (!net_diff || sharediff < net_diff) {
+ flag = use_colors ?
+ (result ? CL_GRN YES : CL_RED BOO)
+ : (result ? "(" YES ")" : "(" BOO ")");
+ } else {
+ solved_count++;
+ flag = use_colors ?
+ (result ? CL_GRN YAY : CL_RED BOO)
+ : (result ? "(" YAY ")" : "(" BOO ")");
+ }
+
+ if (opt_showdiff)
+ sprintf(suppl, "diff %.3f", sharediff);
+ else // accepted percent
+ sprintf(suppl, "%.2f%%", 100. * accepted_count / (accepted_count + rejected_count));
switch (opt_algo) {
case ALGO_AXIOM:
@@ -949,15 +968,15 @@ static int share_result(int result, struct work *work, const char *reason)
case ALGO_PLUCK:
case ALGO_SCRYPTJANE:
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", hashrate);
- applog(LOG_NOTICE, "accepted: %lu/%lu (%.2f%%), %s H/s %s",
+ applog(LOG_NOTICE, "accepted: %lu/%lu (%s), %s H/s %s",
accepted_count, accepted_count + rejected_count,
- 100. * accepted_count / (accepted_count + rejected_count), s, sres);
+ suppl, s, flag);
break;
default:
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", hashrate / 1000.0);
- applog(LOG_NOTICE, "accepted: %lu/%lu (%.2f%%), %s kH/s %s",
+ applog(LOG_NOTICE, "accepted: %lu/%lu (%s), %s kH/s %s",
accepted_count, accepted_count + rejected_count,
- 100. * accepted_count / (accepted_count + rejected_count), s, sres);
+ suppl, s, flag);
break;
}
@@ -1039,6 +1058,9 @@ static bool submit_upstream_work(CURL *curl, struct work *work)
free(xnonce2str);
}
+ // store to keep/display solved blocs (work struct not linked on accept notification)
+ stratum.sharediff = work->sharediff;
+
if (unlikely(!stratum_send_line(&stratum, s))) {
applog(LOG_ERR, "submit_upstream_work stratum_send_line failed");
goto out;

0 comments on commit fb13736

Please sign in to comment.