Add --retry-pause, to set length of pause time between failure retries
This commit is contained in:
parent
714c0fd7c9
commit
e8ee4cb002
1 changed files with 17 additions and 8 deletions
25
cpu-miner.c
25
cpu-miner.c
|
@ -30,10 +30,6 @@
|
||||||
#define DEF_RPC_URL "http://127.0.0.1:8332/"
|
#define DEF_RPC_URL "http://127.0.0.1:8332/"
|
||||||
#define DEF_RPC_USERPASS "rpcuser:rpcpass"
|
#define DEF_RPC_USERPASS "rpcuser:rpcpass"
|
||||||
|
|
||||||
enum {
|
|
||||||
FAILURE_INTERVAL = 30,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum sha256_algos {
|
enum sha256_algos {
|
||||||
ALGO_C, /* plain C */
|
ALGO_C, /* plain C */
|
||||||
ALGO_4WAY, /* parallel SSE2 */
|
ALGO_4WAY, /* parallel SSE2 */
|
||||||
|
@ -60,6 +56,7 @@ bool opt_debug = false;
|
||||||
bool opt_protocol = false;
|
bool opt_protocol = false;
|
||||||
bool opt_quiet = false;
|
bool opt_quiet = false;
|
||||||
static int opt_retries = 10;
|
static int opt_retries = 10;
|
||||||
|
static int opt_fail_pause = 30;
|
||||||
static int opt_scantime = 5;
|
static int opt_scantime = 5;
|
||||||
static const bool opt_time = true;
|
static const bool opt_time = true;
|
||||||
static enum sha256_algos opt_algo = ALGO_C;
|
static enum sha256_algos opt_algo = ALGO_C;
|
||||||
|
@ -105,6 +102,10 @@ static struct option_help options_help[] = {
|
||||||
"(-r N) Number of times to retry, if JSON-RPC call fails\n"
|
"(-r N) Number of times to retry, if JSON-RPC call fails\n"
|
||||||
"\t(default: 10; use -1 for \"never\")" },
|
"\t(default: 10; use -1 for \"never\")" },
|
||||||
|
|
||||||
|
{ "retry-pause N",
|
||||||
|
"(-R N) Number of seconds to pause, between retries\n"
|
||||||
|
"\t(default: 30)" },
|
||||||
|
|
||||||
{ "scantime N",
|
{ "scantime N",
|
||||||
"(-s N) Upper bound on time spent scanning current work,\n"
|
"(-s N) Upper bound on time spent scanning current work,\n"
|
||||||
"\tin seconds. (default: 5)" },
|
"\tin seconds. (default: 5)" },
|
||||||
|
@ -129,6 +130,7 @@ static struct option options[] = {
|
||||||
{ "protocol-dump", 0, NULL, 'P' },
|
{ "protocol-dump", 0, NULL, 'P' },
|
||||||
{ "threads", 1, NULL, 't' },
|
{ "threads", 1, NULL, 't' },
|
||||||
{ "retries", 1, NULL, 'r' },
|
{ "retries", 1, NULL, 'r' },
|
||||||
|
{ "retry-pause", 1, NULL, 'R' },
|
||||||
{ "scantime", 1, NULL, 's' },
|
{ "scantime", 1, NULL, 's' },
|
||||||
{ "url", 1, NULL, 1001 },
|
{ "url", 1, NULL, 1001 },
|
||||||
{ "userpass", 1, NULL, 1002 },
|
{ "userpass", 1, NULL, 1002 },
|
||||||
|
@ -277,8 +279,8 @@ static void *miner_thread(void *thr_id_int)
|
||||||
|
|
||||||
/* pause, then restart work loop */
|
/* pause, then restart work loop */
|
||||||
fprintf(stderr, "retry after %d seconds\n",
|
fprintf(stderr, "retry after %d seconds\n",
|
||||||
FAILURE_INTERVAL);
|
opt_fail_pause);
|
||||||
sleep(FAILURE_INTERVAL);
|
sleep(opt_fail_pause);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,8 +296,8 @@ static void *miner_thread(void *thr_id_int)
|
||||||
|
|
||||||
/* pause, then restart work loop */
|
/* pause, then restart work loop */
|
||||||
fprintf(stderr, "retry after %d seconds\n",
|
fprintf(stderr, "retry after %d seconds\n",
|
||||||
FAILURE_INTERVAL);
|
opt_fail_pause);
|
||||||
sleep(FAILURE_INTERVAL);
|
sleep(opt_fail_pause);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,6 +427,13 @@ static void parse_arg (int key, char *arg)
|
||||||
|
|
||||||
opt_retries = v;
|
opt_retries = v;
|
||||||
break;
|
break;
|
||||||
|
case 'R':
|
||||||
|
v = atoi(arg);
|
||||||
|
if (v < 1 || v > 9999) /* sanity check */
|
||||||
|
show_usage();
|
||||||
|
|
||||||
|
opt_fail_pause = v;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
v = atoi(arg);
|
v = atoi(arg);
|
||||||
if (v < 1 || v > 9999) /* sanity check */
|
if (v < 1 || v > 9999) /* sanity check */
|
||||||
|
|
Loading…
Reference in a new issue