Add --retry-pause, to set length of pause time between failure retries
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
diff --git a/cpu-miner.c b/cpu-miner.c
index c3924a9..5097958 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -30,10 +30,6 @@
#define DEF_RPC_URL "http://127.0.0.1:8332/"
#define DEF_RPC_USERPASS "rpcuser:rpcpass"
-enum {
- FAILURE_INTERVAL = 30,
-};
-
enum sha256_algos {
ALGO_C, /* plain C */
ALGO_4WAY, /* parallel SSE2 */
@@ -60,6 +56,7 @@ bool opt_debug = false;
bool opt_protocol = false;
bool opt_quiet = false;
static int opt_retries = 10;
+static int opt_fail_pause = 30;
static int opt_scantime = 5;
static const bool opt_time = true;
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"
"\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",
"(-s N) Upper bound on time spent scanning current work,\n"
"\tin seconds. (default: 5)" },
@@ -129,6 +130,7 @@ static struct option options[] = {
{ "protocol-dump", 0, NULL, 'P' },
{ "threads", 1, NULL, 't' },
{ "retries", 1, NULL, 'r' },
+ { "retry-pause", 1, NULL, 'R' },
{ "scantime", 1, NULL, 's' },
{ "url", 1, NULL, 1001 },
{ "userpass", 1, NULL, 1002 },
@@ -277,8 +279,8 @@ static void *miner_thread(void *thr_id_int)
/* pause, then restart work loop */
fprintf(stderr, "retry after %d seconds\n",
- FAILURE_INTERVAL);
- sleep(FAILURE_INTERVAL);
+ opt_fail_pause);
+ sleep(opt_fail_pause);
continue;
}
@@ -294,8 +296,8 @@ static void *miner_thread(void *thr_id_int)
/* pause, then restart work loop */
fprintf(stderr, "retry after %d seconds\n",
- FAILURE_INTERVAL);
- sleep(FAILURE_INTERVAL);
+ opt_fail_pause);
+ sleep(opt_fail_pause);
continue;
}
@@ -425,6 +427,13 @@ static void parse_arg (int key, char *arg)
opt_retries = v;
break;
+ case 'R':
+ v = atoi(arg);
+ if (v < 1 || v > 9999) /* sanity check */
+ show_usage();
+
+ opt_fail_pause = v;
+ break;
case 's':
v = atoi(arg);
if (v < 1 || v > 9999) /* sanity check */