From 8f788ec92734ab56a6df174d6013fbad61c73a5c Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 29 Aug 2011 15:12:12 +1000 Subject: [PATCH] Add an option to break out after successfully mining a number of accepted shares. --- main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.c b/main.c index 26fe0786..897aca2e 100644 --- a/main.c +++ b/main.c @@ -218,6 +218,7 @@ static bool use_curses = true; static bool opt_submit_stale; static bool opt_nogpu; static bool opt_usecpu; +static int opt_shares; char *opt_kernel_path; @@ -1149,6 +1150,9 @@ static struct opt_table opt_config_table[] = { OPT_WITH_ARG("--scan-time|-s", set_int_0_to_9999, opt_show_intval, &opt_scantime, "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_set_bool, &opt_submit_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", 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 { cgpu->rejected++; total_rejected++; @@ -4297,6 +4306,9 @@ static void print_summary(void) if (active_device(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(stderr); }