Add configurable timeout
This commit is contained in:
parent
99084f8be4
commit
45024f12f1
4 changed files with 23 additions and 25 deletions
11
README
11
README
|
@ -1,7 +1,4 @@
|
||||||
|
This is a multi-threaded CPU miner for Litecoin, fork of Jeff Garzik's reference cpuminer.
|
||||||
This is a multi-threaded CPU miner for Tenebrix, fork of Jeff Garzik's refernce cpuminer.
|
|
||||||
New, GPU-hostile / CPU-friendly PoW is implemented.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
License: GPLv2. See COPYING for details.
|
License: GPLv2. See COPYING for details.
|
||||||
|
@ -25,9 +22,3 @@ Basic WIN32 build instructions (on Fedora 13; requires mingw32):
|
||||||
|
|
||||||
Usage instructions: Run "minerd --help" to see options.
|
Usage instructions: Run "minerd --help" to see options.
|
||||||
|
|
||||||
REMEMBER - ONLY scrypt ALGORITHM WORKS FOR TENEBRIX !
|
|
||||||
|
|
||||||
Also many issues and FAQs are covered in the forum thread
|
|
||||||
dedicated to this program,
|
|
||||||
http://www.bitcoin.org/smf/index.php?topic=1925.0;all
|
|
||||||
|
|
||||||
|
|
29
cpu-miner.c
29
cpu-miner.c
|
@ -96,6 +96,7 @@ bool use_syslog = false;
|
||||||
static bool opt_quiet = false;
|
static bool opt_quiet = false;
|
||||||
static int opt_retries = 10;
|
static int opt_retries = 10;
|
||||||
static int opt_fail_pause = 30;
|
static int opt_fail_pause = 30;
|
||||||
|
int opt_timeout = 180;
|
||||||
int opt_scantime = 5;
|
int opt_scantime = 5;
|
||||||
static json_t *opt_config;
|
static json_t *opt_config;
|
||||||
static const bool opt_time = true;
|
static const bool opt_time = true;
|
||||||
|
@ -126,8 +127,7 @@ static struct option_help options_help[] = {
|
||||||
"See example-cfg.json for an example configuration." },
|
"See example-cfg.json for an example configuration." },
|
||||||
|
|
||||||
{ "algo XXX",
|
{ "algo XXX",
|
||||||
"(-a XXX) USE *ONLY* scrypt (e.g. --algo scrypt) WITH TENEBRIX\n"
|
"(-a XXX) Only scrypt (e.g. --algo scrypt) is supported" },
|
||||||
"\tscrypt is the default now" },
|
|
||||||
|
|
||||||
{ "quiet",
|
{ "quiet",
|
||||||
"(-q) Disable per-thread hashmeter output (default: off)" },
|
"(-q) Disable per-thread hashmeter output (default: off)" },
|
||||||
|
@ -153,6 +153,9 @@ static struct option_help options_help[] = {
|
||||||
"(-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)" },
|
||||||
|
|
||||||
|
{ "timeout N",
|
||||||
|
"(-T N) Connection timeout, in seconds (default: 180)" },
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
#ifdef HAVE_SYSLOG_H
|
||||||
{ "syslog",
|
{ "syslog",
|
||||||
"Use system log for output messages (default: standard error)" },
|
"Use system log for output messages (default: standard error)" },
|
||||||
|
@ -191,6 +194,7 @@ static struct option options[] = {
|
||||||
{ "retries", 1, NULL, 'r' },
|
{ "retries", 1, NULL, 'r' },
|
||||||
{ "retry-pause", 1, NULL, 'R' },
|
{ "retry-pause", 1, NULL, 'R' },
|
||||||
{ "scantime", 1, NULL, 's' },
|
{ "scantime", 1, NULL, 's' },
|
||||||
|
{ "timeout", 1, NULL, 'T' },
|
||||||
#ifdef HAVE_SYSLOG_H
|
#ifdef HAVE_SYSLOG_H
|
||||||
{ "syslog", 0, NULL, 1004 },
|
{ "syslog", 0, NULL, 1004 },
|
||||||
#endif
|
#endif
|
||||||
|
@ -447,7 +451,7 @@ static void hashmeter(int thr_id, const struct timeval *diff,
|
||||||
secs = (double)diff->tv_sec + ((double)diff->tv_usec / 1000000.0);
|
secs = (double)diff->tv_sec + ((double)diff->tv_usec / 1000000.0);
|
||||||
|
|
||||||
if (!opt_quiet)
|
if (!opt_quiet)
|
||||||
applog(LOG_INFO, "thread %d: %lu hashes, %.2f khash/sec",
|
applog(LOG_INFO, "thread %d: %lu hashes, %.2f khash/s",
|
||||||
thr_id, hashes_done,
|
thr_id, hashes_done,
|
||||||
khashes / secs);
|
khashes / secs);
|
||||||
}
|
}
|
||||||
|
@ -651,15 +655,7 @@ static void *longpoll_thread(void *userdata)
|
||||||
applog(LOG_INFO, "LONGPOLL detected new block");
|
applog(LOG_INFO, "LONGPOLL detected new block");
|
||||||
restart_threads();
|
restart_threads();
|
||||||
} else {
|
} else {
|
||||||
if (failures++ < 10) {
|
/* longpoll failed, keep trying */
|
||||||
sleep(30);
|
|
||||||
applog(LOG_ERR,
|
|
||||||
"longpoll failed, sleeping for 30s");
|
|
||||||
} else {
|
|
||||||
applog(LOG_ERR,
|
|
||||||
"longpoll failed, ending thread");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,6 +750,13 @@ static void parse_arg (int key, char *arg)
|
||||||
|
|
||||||
opt_scantime = v;
|
opt_scantime = v;
|
||||||
break;
|
break;
|
||||||
|
case 'T':
|
||||||
|
v = atoi(arg);
|
||||||
|
if (v < 1 || v > 99999) /* sanity check */
|
||||||
|
show_usage();
|
||||||
|
|
||||||
|
opt_timeout = v;
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
v = atoi(arg);
|
v = atoi(arg);
|
||||||
if (v < 1 || v > 9999) /* sanity check */
|
if (v < 1 || v > 9999) /* sanity check */
|
||||||
|
@ -837,7 +840,7 @@ static void parse_cmdline(int argc, char *argv[])
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
key = getopt_long(argc, argv, "a:c:qDPr:s:t:h?", options, NULL);
|
key = getopt_long(argc, argv, "a:c:qDPr:s:T:t:h?", options, NULL);
|
||||||
if (key < 0)
|
if (key < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
1
miner.h
1
miner.h
|
@ -137,6 +137,7 @@ timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
|
||||||
extern bool fulltest(const unsigned char *hash, const unsigned char *target);
|
extern bool fulltest(const unsigned char *hash, const unsigned char *target);
|
||||||
|
|
||||||
extern int opt_scantime;
|
extern int opt_scantime;
|
||||||
|
extern int opt_timeout;
|
||||||
extern bool want_longpoll;
|
extern bool want_longpoll;
|
||||||
extern bool have_longpoll;
|
extern bool have_longpoll;
|
||||||
struct thread_q;
|
struct thread_q;
|
||||||
|
|
7
util.c
7
util.c
|
@ -211,7 +211,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
||||||
struct curl_slist *headers = NULL;
|
struct curl_slist *headers = NULL;
|
||||||
char len_hdr[64], user_agent_hdr[128];
|
char len_hdr[64], user_agent_hdr[128];
|
||||||
char curl_err_str[CURL_ERROR_SIZE];
|
char curl_err_str[CURL_ERROR_SIZE];
|
||||||
long timeout = longpoll ? (60 * 60) : (60 * 10);
|
long timeout = opt_timeout;
|
||||||
struct header_info hi = { };
|
struct header_info hi = { };
|
||||||
bool lp_scanning = false;
|
bool lp_scanning = false;
|
||||||
|
|
||||||
|
@ -262,7 +262,10 @@ json_t *json_rpc_call(CURL *curl, const char *url,
|
||||||
|
|
||||||
rc = curl_easy_perform(curl);
|
rc = curl_easy_perform(curl);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
applog(LOG_ERR, "HTTP request failed: %s", curl_err_str);
|
if (!(longpoll && rc == CURLE_OPERATION_TIMEDOUT))
|
||||||
|
applog(LOG_ERR, "HTTP request failed: %s", curl_err_str);
|
||||||
|
if (longpoll && rc != CURLE_OPERATION_TIMEDOUT)
|
||||||
|
sleep(30);
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue