|
|
@ -104,6 +104,7 @@ bool opt_quiet = false; |
|
|
|
static int opt_retries = -1; |
|
|
|
static int opt_retries = -1; |
|
|
|
static int opt_fail_pause = 30; |
|
|
|
static int opt_fail_pause = 30; |
|
|
|
int opt_time_limit = -1; |
|
|
|
int opt_time_limit = -1; |
|
|
|
|
|
|
|
int opt_shares_limit = -1; |
|
|
|
time_t firstwork_time = 0; |
|
|
|
time_t firstwork_time = 0; |
|
|
|
int opt_timeout = 300; // curl
|
|
|
|
int opt_timeout = 300; // curl
|
|
|
|
int opt_scantime = 10; |
|
|
|
int opt_scantime = 10; |
|
|
@ -270,6 +271,7 @@ Options:\n\ |
|
|
|
-r, --retries=N number of times to retry if a network call fails\n\ |
|
|
|
-r, --retries=N number of times to retry if a network call fails\n\ |
|
|
|
(default: retry indefinitely)\n\ |
|
|
|
(default: retry indefinitely)\n\ |
|
|
|
-R, --retry-pause=N time to pause between retries, in seconds (default: 30)\n\ |
|
|
|
-R, --retry-pause=N time to pause between retries, in seconds (default: 30)\n\ |
|
|
|
|
|
|
|
--shares-limit maximum shares [s] to mine before exiting the program.\n\ |
|
|
|
--time-limit maximum time [s] to mine before exiting the program.\n\ |
|
|
|
--time-limit maximum time [s] to mine before exiting the program.\n\ |
|
|
|
-T, --timeout=N network timeout, in seconds (default: 300)\n\ |
|
|
|
-T, --timeout=N network timeout, in seconds (default: 300)\n\ |
|
|
|
-s, --scantime=N upper bound on time spent scanning current work when\n\ |
|
|
|
-s, --scantime=N upper bound on time spent scanning current work when\n\ |
|
|
@ -356,6 +358,7 @@ struct option options[] = { |
|
|
|
{ "pool-name", 1, NULL, 1100 }, // pool
|
|
|
|
{ "pool-name", 1, NULL, 1100 }, // pool
|
|
|
|
{ "pool-algo", 1, NULL, 1101 }, // pool
|
|
|
|
{ "pool-algo", 1, NULL, 1101 }, // pool
|
|
|
|
{ "pool-scantime", 1, NULL, 1102 }, // pool
|
|
|
|
{ "pool-scantime", 1, NULL, 1102 }, // pool
|
|
|
|
|
|
|
|
{ "pool-shares-limit", 1, NULL, 1109 }, |
|
|
|
{ "pool-time-limit", 1, NULL, 1108 }, |
|
|
|
{ "pool-time-limit", 1, NULL, 1108 }, |
|
|
|
{ "pool-max-diff", 1, NULL, 1161 }, // pool
|
|
|
|
{ "pool-max-diff", 1, NULL, 1161 }, // pool
|
|
|
|
{ "pool-max-rate", 1, NULL, 1162 }, // pool
|
|
|
|
{ "pool-max-rate", 1, NULL, 1162 }, // pool
|
|
|
@ -377,6 +380,7 @@ struct option options[] = { |
|
|
|
{ "syslog", 0, NULL, 'S' }, |
|
|
|
{ "syslog", 0, NULL, 'S' }, |
|
|
|
{ "syslog-prefix", 1, NULL, 1018 }, |
|
|
|
{ "syslog-prefix", 1, NULL, 1018 }, |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
{ "shares-limit", 1, NULL, 1009 }, |
|
|
|
{ "time-limit", 1, NULL, 1008 }, |
|
|
|
{ "time-limit", 1, NULL, 1008 }, |
|
|
|
{ "threads", 1, NULL, 't' }, |
|
|
|
{ "threads", 1, NULL, 't' }, |
|
|
|
{ "vote", 1, NULL, 1022 }, |
|
|
|
{ "vote", 1, NULL, 1022 }, |
|
|
@ -1806,8 +1810,7 @@ static void *miner_thread(void *userdata) |
|
|
|
int remain = (int)(opt_time_limit - passed); |
|
|
|
int remain = (int)(opt_time_limit - passed); |
|
|
|
if (remain < 0) { |
|
|
|
if (remain < 0) { |
|
|
|
if (thr_id != 0) { |
|
|
|
if (thr_id != 0) { |
|
|
|
sleep(1); |
|
|
|
sleep(1); continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (num_pools > 1 && pools[cur_pooln].time_limit > 0) { |
|
|
|
if (num_pools > 1 && pools[cur_pooln].time_limit > 0) { |
|
|
|
if (!pool_is_switching) { |
|
|
|
if (!pool_is_switching) { |
|
|
@ -1832,8 +1835,7 @@ static void *miner_thread(void *userdata) |
|
|
|
usleep(200*1000); |
|
|
|
usleep(200*1000); |
|
|
|
fprintf(stderr, "%llu\n", (long long unsigned int) global_hashrate); |
|
|
|
fprintf(stderr, "%llu\n", (long long unsigned int) global_hashrate); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
applog(LOG_NOTICE, |
|
|
|
applog(LOG_NOTICE, "Mining timeout of %ds reached, exiting...", opt_time_limit); |
|
|
|
"Mining timeout of %ds reached, exiting...", opt_time_limit); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
workio_abort(); |
|
|
|
workio_abort(); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -1841,6 +1843,36 @@ static void *miner_thread(void *userdata) |
|
|
|
if (remain < max64) max64 = remain; |
|
|
|
if (remain < max64) max64 = remain; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* shares limit */ |
|
|
|
|
|
|
|
if (opt_shares_limit > 0 && firstwork_time) { |
|
|
|
|
|
|
|
int64_t shares = (pools[cur_pooln].accepted_count + pools[cur_pooln].rejected_count); |
|
|
|
|
|
|
|
if (shares >= opt_shares_limit) { |
|
|
|
|
|
|
|
int passed = (int)(time(NULL) - firstwork_time); |
|
|
|
|
|
|
|
if (thr_id != 0) { |
|
|
|
|
|
|
|
sleep(1); continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (num_pools > 1 && pools[cur_pooln].shares_limit > 0) { |
|
|
|
|
|
|
|
if (!pool_is_switching) { |
|
|
|
|
|
|
|
if (!opt_quiet) |
|
|
|
|
|
|
|
applog(LOG_INFO, "Pool shares limit of %d reached, rotate...", opt_shares_limit); |
|
|
|
|
|
|
|
pool_switch_next(thr_id); |
|
|
|
|
|
|
|
} else if (passed > 35) { |
|
|
|
|
|
|
|
// ensure we dont stay locked if pool_is_switching is not reset...
|
|
|
|
|
|
|
|
applog(LOG_WARNING, "Pool switch to %d timed out...", cur_pooln); |
|
|
|
|
|
|
|
if (!thr_id) pools[cur_pooln].wait_time += 1; |
|
|
|
|
|
|
|
pool_is_switching = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sleep(1); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
abort_flag = true; |
|
|
|
|
|
|
|
app_exit_code = EXIT_CODE_OK; |
|
|
|
|
|
|
|
applog(LOG_NOTICE, "Mining limit of %d shares reached, exiting...", opt_shares_limit); |
|
|
|
|
|
|
|
workio_abort(); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
max64 *= (uint32_t)thr_hashrates[thr_id]; |
|
|
|
max64 *= (uint32_t)thr_hashrates[thr_id]; |
|
|
|
|
|
|
|
|
|
|
|
/* on start, max64 should not be 0,
|
|
|
|
/* on start, max64 should not be 0,
|
|
|
@ -2911,6 +2943,9 @@ void parse_arg(int key, char *arg) |
|
|
|
case 1008: |
|
|
|
case 1008: |
|
|
|
opt_time_limit = atoi(arg); |
|
|
|
opt_time_limit = atoi(arg); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 1009: |
|
|
|
|
|
|
|
opt_shares_limit = atoi(arg); |
|
|
|
|
|
|
|
break; |
|
|
|
case 1011: |
|
|
|
case 1011: |
|
|
|
allow_gbt = false; |
|
|
|
allow_gbt = false; |
|
|
|
break; |
|
|
|
break; |
|
|
@ -3045,6 +3080,9 @@ void parse_arg(int key, char *arg) |
|
|
|
case 1108: /* pool time-limit */ |
|
|
|
case 1108: /* pool time-limit */ |
|
|
|
pool_set_attr(cur_pooln, "time-limit", arg); |
|
|
|
pool_set_attr(cur_pooln, "time-limit", arg); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 1109: /* pool shares-limit (1.7.6) */ |
|
|
|
|
|
|
|
pool_set_attr(cur_pooln, "shares-limit", arg); |
|
|
|
|
|
|
|
break; |
|
|
|
case 1161: /* pool max-diff */ |
|
|
|
case 1161: /* pool max-diff */ |
|
|
|
pool_set_attr(cur_pooln, "max-diff", arg); |
|
|
|
pool_set_attr(cur_pooln, "max-diff", arg); |
|
|
|
break; |
|
|
|
break; |
|
|
|