Fix max-nonce auto-adjustment logic to actually work
This commit is contained in:
parent
51eb1b4ef9
commit
e47076caac
1 changed files with 8 additions and 10 deletions
18
cpu-miner.c
18
cpu-miner.c
|
@ -54,7 +54,7 @@ static const char *algo_names[] = {
|
||||||
|
|
||||||
bool opt_debug = false;
|
bool opt_debug = false;
|
||||||
bool opt_protocol = false;
|
bool opt_protocol = false;
|
||||||
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;
|
||||||
static int opt_scantime = 5;
|
static int opt_scantime = 5;
|
||||||
|
@ -258,12 +258,12 @@ static void *miner_thread(void *thr_id_int)
|
||||||
int failures = 0;
|
int failures = 0;
|
||||||
static const char *rpc_req =
|
static const char *rpc_req =
|
||||||
"{\"method\": \"getwork\", \"params\": [], \"id\":0}\r\n";
|
"{\"method\": \"getwork\", \"params\": [], \"id\":0}\r\n";
|
||||||
|
uint32_t max_nonce = 0xffffff;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
struct work work __attribute__((aligned(128)));
|
struct work work __attribute__((aligned(128)));
|
||||||
unsigned long hashes_done;
|
unsigned long hashes_done;
|
||||||
struct timeval tv_start, tv_end, diff;
|
struct timeval tv_start, tv_end, diff;
|
||||||
uint32_t max_nonce = 0xffffff;
|
|
||||||
json_t *val;
|
json_t *val;
|
||||||
bool rc;
|
bool rc;
|
||||||
|
|
||||||
|
@ -360,14 +360,12 @@ static void *miner_thread(void *thr_id_int)
|
||||||
/* adjust max_nonce to meet target scan time */
|
/* adjust max_nonce to meet target scan time */
|
||||||
if (diff.tv_sec > (opt_scantime * 2))
|
if (diff.tv_sec > (opt_scantime * 2))
|
||||||
max_nonce /= 2; /* large decrease */
|
max_nonce /= 2; /* large decrease */
|
||||||
else if (diff.tv_sec > opt_scantime)
|
else if ((diff.tv_sec > opt_scantime) &&
|
||||||
max_nonce -= 1000; /* small decrease */
|
(max_nonce > 1500000))
|
||||||
else if (diff.tv_sec < (opt_scantime - 1))
|
max_nonce -= 1000000; /* small decrease */
|
||||||
max_nonce += 1000; /* small increase */
|
else if ((diff.tv_sec < opt_scantime) &&
|
||||||
|
(max_nonce < 0xffffec76))
|
||||||
/* catch stupidly slow cases, such as simulators */
|
max_nonce += 100000; /* small increase */
|
||||||
if (max_nonce < 1000)
|
|
||||||
max_nonce = 1000;
|
|
||||||
|
|
||||||
/* if nonce found, submit work */
|
/* if nonce found, submit work */
|
||||||
if (rc)
|
if (rc)
|
||||||
|
|
Loading…
Reference in a new issue