Browse Source

handle option --shares-limit like sgminer --shares

--shares alone was confusing imo, but it also works on command line

Allowed in multi pool settings too...
master
Tanguy Pruvot 9 years ago
parent
commit
b6a2c5c2ec
  1. 4
      README.txt
  2. 46
      ccminer.cpp
  3. 1
      miner.h
  4. 8
      pools.cpp

4
README.txt

@ -129,6 +129,7 @@ its command line interface and options. @@ -129,6 +129,7 @@ its command line interface and options.
-r, --retries=N number of times to retry if a network call fails
(default: retry indefinitely)
-R, --retry-pause=N time to pause between retries, in seconds (default: 15)
--shares-limit maximum shares to mine before exiting the program.
--time-limit maximum time [s] to mine before exiting the program.
-T, --timeout=N network timeout, in seconds (default: 300)
-s, --scantime=N upper bound on time spent scanning current work when
@ -238,11 +239,12 @@ features. @@ -238,11 +239,12 @@ features.
>>> RELEASE HISTORY <<<
May 15th 2016 v1.7.6
May 18th 2016 v1.7.6
Decred vote support
X17 cleanup and improvement
Add mining.ping stratum method and handle unknown methods
Implement a pool stats/benchmark mode (-p stats on yiimp)
Add --shares-limit parameter, can be used for benchmarks
Mar. 13th 2016 v1.7.5
Blake2S Algo (NEVA/OXEN)

46
ccminer.cpp

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

1
miner.h

@ -675,6 +675,7 @@ struct pool_infos { @@ -675,6 +675,7 @@ struct pool_infos {
// config options
double max_diff;
double max_rate;
int shares_limit;
int time_limit;
int scantime;
// connection

8
pools.cpp

@ -19,6 +19,7 @@ extern bool check_dups; @@ -19,6 +19,7 @@ extern bool check_dups;
extern double opt_max_diff;
extern double opt_max_rate;
extern int opt_scantime;
extern int opt_shares_limit;
extern int opt_time_limit;
extern char* rpc_url;
@ -83,6 +84,7 @@ void pool_set_creds(int pooln) @@ -83,6 +84,7 @@ void pool_set_creds(int pooln)
p->max_diff = -1.;
p->max_rate = -1.;
p->scantime = -1;
p->shares_limit = -1;
p->time_limit = -1;
p->allow_mininginfo = allow_mininginfo;
@ -111,6 +113,7 @@ void pool_init_defaults() @@ -111,6 +113,7 @@ void pool_init_defaults()
if (p->max_diff == -1.) p->max_diff = opt_max_diff;
if (p->max_rate == -1.) p->max_rate = opt_max_rate;
if (p->scantime == -1) p->scantime = opt_scantime;
if (p->shares_limit == -1) p->shares_limit = opt_shares_limit;
if (p->time_limit == -1) p->time_limit = opt_time_limit;
}
}
@ -139,6 +142,10 @@ void pool_set_attr(int pooln, const char* key, char* arg) @@ -139,6 +142,10 @@ void pool_set_attr(int pooln, const char* key, char* arg)
p->max_rate = atof(arg);
return;
}
if (!strcasecmp(key, "shares-limit")) {
p->shares_limit = atoi(arg);
return;
}
if (!strcasecmp(key, "time-limit")) {
p->time_limit = atoi(arg);
return;
@ -192,6 +199,7 @@ bool pool_switch(int thr_id, int pooln) @@ -192,6 +199,7 @@ bool pool_switch(int thr_id, int pooln)
opt_scantime = p->scantime;
opt_max_diff = p->max_diff;
opt_max_rate = p->max_rate;
opt_shares_limit = p->shares_limit;
opt_time_limit = p->time_limit;
want_stratum = have_stratum = (p->type & POOL_STRATUM) != 0;

Loading…
Cancel
Save