Browse Source

Add an option to break out after successfully mining a number of accepted shares.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
8f788ec927
  1. 12
      main.c

12
main.c

@ -218,6 +218,7 @@ static bool use_curses = true;
static bool opt_submit_stale; static bool opt_submit_stale;
static bool opt_nogpu; static bool opt_nogpu;
static bool opt_usecpu; static bool opt_usecpu;
static int opt_shares;
char *opt_kernel_path; char *opt_kernel_path;
@ -1149,6 +1150,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--scan-time|-s", OPT_WITH_ARG("--scan-time|-s",
set_int_0_to_9999, opt_show_intval, &opt_scantime, set_int_0_to_9999, opt_show_intval, &opt_scantime,
"Upper bound on time spent scanning current work, in seconds"), "Upper bound on time spent scanning current work, in seconds"),
OPT_WITH_ARG("--shares",
opt_set_intval, NULL, &opt_shares,
"Quit after mining N shares (default: unlimited)"),
OPT_WITHOUT_ARG("--submit-stale", OPT_WITHOUT_ARG("--submit-stale",
opt_set_bool, &opt_submit_stale, opt_set_bool, &opt_submit_stale,
"Submit shares even if they would normally be considered stale"), "Submit shares even if they would normally be considered stale"),
@ -1602,6 +1606,11 @@ static bool submit_upstream_work(const struct work *work)
applog(LOG_WARNING, "Accepted %.8s %sPU %d thread %d", applog(LOG_WARNING, "Accepted %.8s %sPU %d thread %d",
hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id); hexstr + 152, cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, thr_id);
} }
if (opt_shares && total_accepted >= opt_shares) {
applog(LOG_WARNING, "Successfully mined %d accepted shares as requested and exiting.", opt_shares);
kill_work();
goto out;
}
} else { } else {
cgpu->rejected++; cgpu->rejected++;
total_rejected++; total_rejected++;
@ -4297,6 +4306,9 @@ static void print_summary(void)
if (active_device(i)) if (active_device(i))
log_print_status(i); log_print_status(i);
} }
if (opt_shares)
applog(LOG_WARNING, "Mined %d accepted shares of %d requested\n", total_accepted, opt_shares);
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
} }

Loading…
Cancel
Save