|
|
@ -171,6 +171,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; |
|
|
|
static bool opt_background = false; |
|
|
|
static bool opt_background = false; |
|
|
|
static bool opt_quiet = false; |
|
|
|
static bool opt_quiet = false; |
|
|
|
static int opt_retries = -1; |
|
|
|
static int opt_retries = -1; |
|
|
@ -261,6 +262,7 @@ Options:\n\ |
|
|
|
--no-longpoll disable X-Long-Polling support\n\ |
|
|
|
--no-longpoll disable X-Long-Polling support\n\ |
|
|
|
--no-stratum disable X-Stratum support\n\ |
|
|
|
--no-stratum disable X-Stratum support\n\ |
|
|
|
-q, --quiet disable per-thread hashmeter output\n\ |
|
|
|
-q, --quiet disable per-thread hashmeter output\n\ |
|
|
|
|
|
|
|
-C, --color enable colored output\n\ |
|
|
|
-D, --debug enable debug 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" |
|
|
|
#ifdef HAVE_SYSLOG_H |
|
|
|
#ifdef HAVE_SYSLOG_H |
|
|
@ -286,7 +288,7 @@ static char const short_options[] = |
|
|
|
#ifdef HAVE_SYSLOG_H |
|
|
|
#ifdef HAVE_SYSLOG_H |
|
|
|
"S" |
|
|
|
"S" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
"a:c:Dhp:Px:qr:R:s:t:T:o:u:O:Vd:f:mv:"; |
|
|
|
"a:c:CDhp:Px:qr:R:s:t:T:o:u:O:Vd:f:mv:"; |
|
|
|
|
|
|
|
|
|
|
|
static struct option const options[] = { |
|
|
|
static struct option const options[] = { |
|
|
|
{ "algo", 1, NULL, 'a' }, |
|
|
|
{ "algo", 1, NULL, 'a' }, |
|
|
@ -297,6 +299,7 @@ static struct option const options[] = { |
|
|
|
{ "cputest", 0, NULL, 1006 }, |
|
|
|
{ "cputest", 0, NULL, 1006 }, |
|
|
|
{ "cert", 1, NULL, 1001 }, |
|
|
|
{ "cert", 1, NULL, 1001 }, |
|
|
|
{ "config", 1, NULL, 'c' }, |
|
|
|
{ "config", 1, NULL, 'c' }, |
|
|
|
|
|
|
|
{ "color", 0, NULL, 'C' }, |
|
|
|
{ "debug", 0, NULL, 'D' }, |
|
|
|
{ "debug", 0, NULL, 'D' }, |
|
|
|
{ "help", 0, NULL, 'h' }, |
|
|
|
{ "help", 0, NULL, 'h' }, |
|
|
|
{ "no-longpoll", 0, NULL, 1003 }, |
|
|
|
{ "no-longpoll", 0, NULL, 1003 }, |
|
|
@ -403,12 +406,14 @@ static void share_result(int result, const char *reason) |
|
|
|
pthread_mutex_unlock(&stats_lock); |
|
|
|
pthread_mutex_unlock(&stats_lock); |
|
|
|
|
|
|
|
|
|
|
|
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate); |
|
|
|
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate); |
|
|
|
applog(LOG_INFO, "accepted: %lu/%lu (%.2f%%), %s khash/s %s", |
|
|
|
applog(LOG_NOTICE, "accepted: %lu/%lu (%.2f%%), %s khash/s %s", |
|
|
|
accepted_count, |
|
|
|
accepted_count, |
|
|
|
accepted_count + rejected_count, |
|
|
|
accepted_count + rejected_count, |
|
|
|
100. * accepted_count / (accepted_count + rejected_count), |
|
|
|
100. * accepted_count / (accepted_count + rejected_count), |
|
|
|
s, |
|
|
|
s, |
|
|
|
result ? "(yay!!!)" : "(booooo)"); |
|
|
|
use_colors ? |
|
|
|
|
|
|
|
(result ? CL_GRN "(yay!!!)" : CL_RED "(booooo)") |
|
|
|
|
|
|
|
: (result ? "(yay!!!)" : "(booooo)")); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug && reason) |
|
|
|
if (opt_debug && reason) |
|
|
|
applog(LOG_DEBUG, "DEBUG: reject reason: %s", reason); |
|
|
|
applog(LOG_DEBUG, "DEBUG: reject reason: %s", reason); |
|
|
@ -595,8 +600,9 @@ static bool workio_submit_work(struct workio_cmd *wc, CURL *curl) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* pause, then restart work-request loop */ |
|
|
|
/* pause, then restart work-request loop */ |
|
|
|
applog(LOG_ERR, "...retry after %d seconds", |
|
|
|
if (!opt_benchmark) |
|
|
|
opt_fail_pause); |
|
|
|
applog(LOG_ERR, "...retry after %d seconds", opt_fail_pause); |
|
|
|
|
|
|
|
|
|
|
|
sleep(opt_fail_pause); |
|
|
|
sleep(opt_fail_pause); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -820,8 +826,8 @@ static void *miner_thread(void *userdata) |
|
|
|
* of the number of CPUs */ |
|
|
|
* of the number of CPUs */ |
|
|
|
if (num_processors > 1 && opt_n_threads % num_processors == 0) { |
|
|
|
if (num_processors > 1 && opt_n_threads % num_processors == 0) { |
|
|
|
if (!opt_quiet) |
|
|
|
if (!opt_quiet) |
|
|
|
applog(LOG_INFO, "Binding thread %d to cpu %d", |
|
|
|
applog(LOG_DEBUG, "Binding thread %d to cpu %d", thr_id, |
|
|
|
thr_id, thr_id % num_processors); |
|
|
|
thr_id % num_processors); |
|
|
|
affine_to_cpu(thr_id, thr_id % num_processors); |
|
|
|
affine_to_cpu(thr_id, thr_id % num_processors); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -985,8 +991,8 @@ static void *miner_thread(void *userdata) |
|
|
|
for (i = 0; i < opt_n_threads && thr_hashrates[i]; i++) |
|
|
|
for (i = 0; i < opt_n_threads && thr_hashrates[i]; i++) |
|
|
|
hashrate += thr_hashrates[i]; |
|
|
|
hashrate += thr_hashrates[i]; |
|
|
|
if (i == opt_n_threads) { |
|
|
|
if (i == opt_n_threads) { |
|
|
|
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate); |
|
|
|
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", hashrate / 1000.); |
|
|
|
applog(LOG_INFO, "Total: %s khash/s", s); |
|
|
|
applog(LOG_NOTICE, "Total: %s khash/s", s); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1066,7 +1072,7 @@ start: |
|
|
|
pthread_mutex_lock(&g_work_lock); |
|
|
|
pthread_mutex_lock(&g_work_lock); |
|
|
|
if (work_decode(json_object_get(val, "result"), &g_work)) { |
|
|
|
if (work_decode(json_object_get(val, "result"), &g_work)) { |
|
|
|
if (opt_debug) |
|
|
|
if (opt_debug) |
|
|
|
applog(LOG_DEBUG, "DEBUG: got new work"); |
|
|
|
applog(LOG_BLUE, "LONGPOLL pushed new work"); |
|
|
|
time(&g_work_time); |
|
|
|
time(&g_work_time); |
|
|
|
restart_threads(); |
|
|
|
restart_threads(); |
|
|
|
} |
|
|
|
} |
|
|
@ -1158,7 +1164,8 @@ static void *stratum_thread(void *userdata) |
|
|
|
tq_push(thr_info[work_thr_id].q, NULL); |
|
|
|
tq_push(thr_info[work_thr_id].q, NULL); |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
applog(LOG_ERR, "...retry after %d seconds", opt_fail_pause); |
|
|
|
if (!opt_benchmark) |
|
|
|
|
|
|
|
applog(LOG_ERR, "...retry after %d seconds", opt_fail_pause); |
|
|
|
sleep(opt_fail_pause); |
|
|
|
sleep(opt_fail_pause); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1170,7 +1177,7 @@ static void *stratum_thread(void *userdata) |
|
|
|
time(&g_work_time); |
|
|
|
time(&g_work_time); |
|
|
|
pthread_mutex_unlock(&g_work_lock); |
|
|
|
pthread_mutex_unlock(&g_work_lock); |
|
|
|
if (stratum.job.clean) { |
|
|
|
if (stratum.job.clean) { |
|
|
|
if (!opt_quiet) applog(LOG_INFO, "Stratum detected new block"); |
|
|
|
if (!opt_quiet) applog(LOG_BLUE, "Stratum detected new block"); |
|
|
|
restart_threads(); |
|
|
|
restart_threads(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1245,6 +1252,9 @@ static void parse_arg (int key, char *arg) |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
case 'C': |
|
|
|
|
|
|
|
use_colors = true; |
|
|
|
|
|
|
|
break; |
|
|
|
case 'q': |
|
|
|
case 'q': |
|
|
|
opt_quiet = true; |
|
|
|
opt_quiet = true; |
|
|
|
break; |
|
|
|
break; |
|
|
@ -1428,6 +1438,9 @@ static void parse_arg (int key, char *arg) |
|
|
|
default: |
|
|
|
default: |
|
|
|
show_usage_and_exit(1); |
|
|
|
show_usage_and_exit(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (use_syslog) |
|
|
|
|
|
|
|
use_colors = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void parse_config(void) |
|
|
|
static void parse_config(void) |
|
|
|