Browse Source

enable colors by default, except for syslog

debug: show compared hash diffs in color
2upstream
Tanguy Pruvot 10 years ago
parent
commit
cec5baea95
  1. 2
      blake32.cu
  2. 22
      cpu-miner.c
  3. 1
      miner.h
  4. 14
      util.c

2
blake32.cu

@ -361,7 +361,7 @@ extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *pt
be32enc(&endiandata[19], extra_results[0]); be32enc(&endiandata[19], extra_results[0]);
blake256hash(vhashcpu, endiandata, blakerounds); blake256hash(vhashcpu, endiandata, blakerounds);
if (vhashcpu[7] <= Htarg && fulltest(vhashcpu, ptarget)) { if (vhashcpu[7] <= Htarg && fulltest(vhashcpu, ptarget)) {
applog(LOG_NOTICE, "GPU found more than one result yippee!"); applog(LOG_NOTICE, "GPU found more than one result " CL_GRN "yippee!");
rc = 2; rc = 2;
} else { } else {
extra_results[0] = MAXU; extra_results[0] = MAXU;

22
cpu-miner.c

@ -181,7 +181,7 @@ bool want_stratum = true;
bool have_stratum = false; bool have_stratum = false;
static bool submit_old = false; static bool submit_old = false;
bool use_syslog = false; bool use_syslog = false;
bool use_colors = false; bool use_colors = true;
static bool opt_background = false; static bool opt_background = false;
bool opt_quiet = false; bool opt_quiet = false;
static int opt_retries = -1; static int opt_retries = -1;
@ -940,12 +940,11 @@ static void *miner_thread(void *userdata)
} }
if (memcmp(work.data, g_work.data, wcmplen)) { if (memcmp(work.data, g_work.data, wcmplen)) {
if (opt_debug) { if (opt_debug) {
applog(LOG_DEBUG, "job %s work updated", g_work.job_id); for (int n=0; n <= (wcmplen-8); n+=8) {
for (int n=0; n<wcmplen; n+=8) {
if (memcmp(work.data + n, g_work.data + n, 8)) { if (memcmp(work.data + n, g_work.data + n, 8)) {
applog(LOG_DEBUG, "diff detected at offset %d", n); applog(LOG_DEBUG, "job %s work updated at offset %d:", g_work.job_id, n);
applog_hash((uint8_t*) work.data + n); applog_hash((uint8_t*) work.data + n);
applog_hash((uint8_t*) g_work.data + n); applog_compare_hash((uint8_t*) g_work.data + n, (uint8_t*) work.data + n);
} }
} }
} }
@ -953,9 +952,9 @@ static void *miner_thread(void *userdata)
(*nonceptr) = (0xffffffffUL / opt_n_threads) * thr_id; // 0 if single thr (*nonceptr) = (0xffffffffUL / opt_n_threads) * thr_id; // 0 if single thr
} else if (memcmp(work.target, g_work.target, sizeof(work.target))) { } else if (memcmp(work.target, g_work.target, sizeof(work.target))) {
if (opt_debug) { if (opt_debug) {
applog(LOG_DEBUG, "job %s target change", g_work.job_id); applog(LOG_DEBUG, "job %s target change:", g_work.job_id);
applog_hash((uint8_t*) work.target); applog_hash((uint8_t*) work.target);
applog_hash((uint8_t*) g_work.target); applog_compare_hash((uint8_t*) g_work.target, (uint8_t*) work.target);
} }
memcpy(work.target, g_work.target, sizeof(work.target)); memcpy(work.target, g_work.target, sizeof(work.target));
(*nonceptr) = (0xffffffffUL / opt_n_threads) * thr_id; // 0 if single thr (*nonceptr) = (0xffffffffUL / opt_n_threads) * thr_id; // 0 if single thr
@ -1021,7 +1020,7 @@ static void *miner_thread(void *userdata)
stall |= (start_nonce > range.scanned[0] && start_nonce < range.scanned[1]); stall |= (start_nonce > range.scanned[0] && start_nonce < range.scanned[1]);
if (stall) { if (stall) {
if (opt_algo) if (opt_debug && !opt_quiet)
applog(LOG_DEBUG, "job done, wait for a new one..."); applog(LOG_DEBUG, "job done, wait for a new one...");
work_restart[thr_id].restart = 1; work_restart[thr_id].restart = 1;
hashlog_purge_old(); hashlog_purge_old();
@ -1464,13 +1463,14 @@ static void parse_arg (int key, char *arg)
case 'C': case 'C':
use_colors = true; use_colors = true;
break; break;
case 'q':
opt_quiet = true;
break;
case 'D': case 'D':
opt_debug = true; opt_debug = true;
opt_debug_rpc = true; opt_debug_rpc = true;
break; break;
case 'q':
opt_quiet = true;
opt_debug_rpc = false;
break;
case 'p': case 'p':
free(rpc_pass); free(rpc_pass);
rpc_pass = strdup(arg); rpc_pass = strdup(arg);

1
miner.h

@ -422,6 +422,7 @@ size_t time2str(char* buf, time_t timer);
char* atime2str(time_t timer); char* atime2str(time_t timer);
void applog_hash(unsigned char *hash); void applog_hash(unsigned char *hash);
void applog_compare_hash(unsigned char *hash, unsigned char *hash2);
void print_hash_tests(void); void print_hash_tests(void);
void animehash(void *state, const void *input); void animehash(void *state, const void *input);

14
util.c

@ -1401,6 +1401,20 @@ static char* format_hash(char* buf, unsigned char *hash)
return buf; return buf;
} }
/* to debug diff in data */
extern void applog_compare_hash(unsigned char *hash, unsigned char *hash2)
{
char s[256] = "";
int len = 0;
for (int i=0; i < 32; i += 4) {
char *color = memcmp(hash+i, hash2+i, 4) ? CL_RED : CL_GRY;
len += sprintf(s+len, "%s%02x%02x%02x%02x " CL_GRY, color,
hash[i], hash[i+1], hash[i+2], hash[i+3]);
s[len] = '\0';
}
applog(LOG_DEBUG, "%s", s);
}
extern void applog_hash(unsigned char *hash) extern void applog_hash(unsigned char *hash)
{ {
char s[128] = {'\0'}; char s[128] = {'\0'};

Loading…
Cancel
Save