From 712385160b4d0fa2fc89f26f2497f19e67524c4d Mon Sep 17 00:00:00 2001 From: Joe4782 Date: Thu, 23 Jan 2014 21:54:40 +0000 Subject: [PATCH 1/6] Added the stratum port to the status print --- sgminer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sgminer.c b/sgminer.c index ffe4d5c0..ebeca002 100644 --- a/sgminer.c +++ b/sgminer.c @@ -2039,8 +2039,8 @@ static void curses_print_status(void) cg_mvwprintw(statuswin, 4, 0, "Connected to multiple pools with%s block change notify", have_longpoll ? "": "out"); } else if (pool->has_stratum) { - cg_mvwprintw(statuswin, 4, 0, "Connected to %s diff %s with stratum as user %s", - pool->sockaddr_url, pool->diff, pool->rpc_user); + cg_mvwprintw(statuswin, 4, 0, "Connected to %s:%s diff %s with stratum as user %s", + pool->sockaddr_url, pool->stratum_port, pool->diff, pool->rpc_user); } else { cg_mvwprintw(statuswin, 4, 0, "Connected to %s diff %s with%s %s as user %s", pool->sockaddr_url, pool->diff, have_longpoll ? "": "out", From 1d8119623866d692b5a2d2b48a96bc9926d12c69 Mon Sep 17 00:00:00 2001 From: Joe4782 Date: Sat, 25 Jan 2014 20:33:45 +0000 Subject: [PATCH 2/6] Added a 'disable-pool' option to the json configuration, to allow pools to be started up disabled --- miner.h | 1 + sgminer.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/miner.h b/miner.h index a74e3056..657f6dcb 100644 --- a/miner.h +++ b/miner.h @@ -1177,6 +1177,7 @@ struct pool { bool idle; bool lagging; bool probed; + bool start_disabled; enum pool_enable enabled; bool submit_old; bool removed; diff --git a/sgminer.c b/sgminer.c index ebeca002..a4465999 100644 --- a/sgminer.c +++ b/sgminer.c @@ -211,6 +211,7 @@ int total_pools, enabled_pools; enum pool_strategy pool_strategy = POOL_FAILOVER; int opt_rotate_period; static int total_urls, total_users, total_passes, total_userpasses, total_poolnames; +static int json_array_index; static #ifndef HAVE_CURSES @@ -741,6 +742,29 @@ static char *set_poolname(char *arg) return NULL; } +static char *set_disable_pool(char *arg) +{ + struct pool *pool; + int len, disabled; + + while ((json_array_index + 1) > total_pools) + add_pool(); + pool = pools[json_array_index]; + + len = strlen(arg); + if (len < 0) + { + disabled = 1; + } + else + { + disabled = atoi(arg); + } + pool->start_disabled = (disabled > 0); + + return NULL; +} + static char *set_quota(char *arg) { char *semicolon = strchr(arg, ';'), *url; @@ -1024,6 +1048,9 @@ static struct opt_table opt_config_table[] = { OPT_WITH_ARG("--device|-d", set_devices, NULL, NULL, "Select device to use, one value, range and/or comma separated (e.g. 0-2,4) default: all"), + OPT_WITH_ARG("--disable-pool", + set_disable_pool, NULL, NULL, + "Start the pool in a disabled state, so that it is not automatically chosen for mining"), OPT_WITHOUT_ARG("--disable-rejecting", opt_set_bool, &opt_disable_pool, "Automatically disable pools that continually reject shares"), @@ -1254,12 +1281,14 @@ static char *load_config(const char *arg, void __maybe_unused *unused); static int fileconf_load; -static char *parse_config(json_t *config, bool fileconf) +static char *parse_config(json_t *config, bool fileconf, int parent_iteration) { static char err_buf[200]; struct opt_table *opt; json_t *val; + json_array_index = parent_iteration; + if (fileconf && !fileconf_load) fileconf_load = 1; @@ -1295,7 +1324,10 @@ static char *parse_config(json_t *config, bool fileconf) if (json_is_string(json_array_get(val, n))) err = opt->cb_arg(json_string_value(json_array_get(val, n)), opt->u.arg); else if (json_is_object(json_array_get(val, n))) - err = parse_config(json_array_get(val, n), false); + { + err = parse_config(json_array_get(val, n), false, n); + json_array_index = parent_iteration; + } } } else if ((opt->type & OPT_NOARG) && json_is_true(val)) err = opt->cb(opt->u.arg); @@ -1360,7 +1392,7 @@ static char *load_config(const char *arg, void __maybe_unused *unused) /* Parse the config now, so we can override it. That can keep pointers * so don't free config object. */ - return parse_config(config, true); + return parse_config(config, true, 0); } static char *set_default_config(const char *arg) @@ -7843,7 +7875,14 @@ int main(int argc, char *argv[]) for (i = 0; i < total_pools; i++) { struct pool *pool = pools[i]; - enable_pool(pool); + if (pool->start_disabled) + { + disable_pool(pool); + } + else + { + enable_pool(pool); + } pool->idle = true; } From dd7bd69786a8b4db0990f1e5d2b37889ce418f4f Mon Sep 17 00:00:00 2001 From: Joe4782 Date: Sun, 26 Jan 2014 00:17:56 +0000 Subject: [PATCH 3/6] Updated README to explain new 'disable-pool' configuration file option --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 7a3fdb2a..549d63fa 100644 --- a/README.md +++ b/README.md @@ -331,6 +331,31 @@ the above quotas in a configuration file they would be specified thus: } ] +### Extra File Configuration + +If you want to store a number of pools in your configuration file, but don't always +want them automatically enabled at start up (or restart), then the new "disable-pool" +option can be used: + + "pools" : [ + { + "url" : "poola:porta", + "user" : "usernamea", + "pass" : "passa" + }, + { + "quota" : "2;poolb:portb", + "user" : "usernameb", + "pass" : "passb", + "disable-pool" : "1" + } + ] + +It is then trivial to change the "disable-pool" setting to "0" in the configuration file +at anytime and then restart the miner ('s' followed by 'c'). Or, you can enable the pool +whilst the miner is still running ('p' followed by 'e' followed by pool number) - but the +pool be still be disabled on restart if the config file is not changed. This option is +NOT created when the 'Write config file' option is used ('s' followed by 'w'). ## Logging From 817ed55b6aeed63b1c3c1898fa4290ba89c4e174 Mon Sep 17 00:00:00 2001 From: Joe4782 Date: Sun, 26 Jan 2014 00:56:58 +0000 Subject: [PATCH 4/6] Pool management option now shows pool name when available --- sgminer.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sgminer.c b/sgminer.c index a4465999..cf216ddf 100644 --- a/sgminer.c +++ b/sgminer.c @@ -752,7 +752,7 @@ static char *set_disable_pool(char *arg) pool = pools[json_array_index]; len = strlen(arg); - if (len < 0) + if (len < 1) { disabled = 1; } @@ -4397,6 +4397,7 @@ static void display_pools(void) struct pool *pool; int selected, i; char input; + char *disp_name; opt_loginput = true; immedok(logwin, true); @@ -4421,11 +4422,16 @@ static void display_pools(void) wlogprint("Rejecting "); break; } - wlogprint("%s Quota %d Prio %d: %s User:%s\n", + disp_name = pool->poolname; + if (strlen(disp_name) < 1) + { + disp_name = pool->rpc_url; + } + wlogprint("%s Quota %d Prio %d: '%s' User:%s\n", pool->idle? "Dead" : "Alive", pool->quota, pool->prio, - pool->rpc_url, pool->rpc_user); + disp_name, pool->rpc_user); wattroff(logwin, A_BOLD | A_DIM); } retry: From b1eb2ab8f8e6dfa8e18fea5f8b7c735969a71088 Mon Sep 17 00:00:00 2001 From: Joe4782 Date: Sun, 26 Jan 2014 01:26:00 +0000 Subject: [PATCH 5/6] Implemented the 'remove-pool' config option for json file pools --- miner.h | 1 + sgminer.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/miner.h b/miner.h index 657f6dcb..2033862f 100644 --- a/miner.h +++ b/miner.h @@ -1180,6 +1180,7 @@ struct pool { bool start_disabled; enum pool_enable enabled; bool submit_old; + bool remove_at_start; bool removed; bool lp_started; diff --git a/sgminer.c b/sgminer.c index cf216ddf..930e5d75 100644 --- a/sgminer.c +++ b/sgminer.c @@ -765,6 +765,29 @@ static char *set_disable_pool(char *arg) return NULL; } +static char *set_remove_pool(char *arg) +{ + struct pool *pool; + int len, remove; + + while ((json_array_index + 1) > total_pools) + add_pool(); + pool = pools[json_array_index]; + + len = strlen(arg); + if (len < 1) + { + remove = 1; + } + else + { + remove = atoi(arg); + } + pool->remove_at_start = (remove > 0); + + return NULL; +} + static char *set_quota(char *arg) { char *semicolon = strchr(arg, ';'), *url; @@ -1051,6 +1074,9 @@ static struct opt_table opt_config_table[] = { OPT_WITH_ARG("--disable-pool", set_disable_pool, NULL, NULL, "Start the pool in a disabled state, so that it is not automatically chosen for mining"), + OPT_WITH_ARG("--remove-pool", + set_remove_pool, NULL, NULL, + "Allow the pool configuration to remain in the config file, but exclude it from the pools available at runtime"), OPT_WITHOUT_ARG("--disable-rejecting", opt_set_bool, &opt_disable_pool, "Automatically disable pools that continually reject shares"), @@ -7878,6 +7904,18 @@ int main(int argc, char *argv[]) if (opt_benchmark) goto begin_bench; + /* Remove any pools that are in the configuration, but have been marked to be + * removed at miner startup in order to reduce clutter in the pool management */ + for (i = 0; i < total_pools; i++) { + struct pool *pool = pools[i]; + + if (pool->remove_at_start) + { + remove_pool(pool); + } + } + + /* Enable or disable all the 'remaining' pools */ for (i = 0; i < total_pools; i++) { struct pool *pool = pools[i]; From 90d49e9ad3a2a782ea939c60447db800e999b5fd Mon Sep 17 00:00:00 2001 From: Joe4782 Date: Sun, 26 Jan 2014 01:37:30 +0000 Subject: [PATCH 6/6] Updated the README file to explain the 'remove-pool' json config file option --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 549d63fa..0fc6f20f 100644 --- a/README.md +++ b/README.md @@ -357,6 +357,30 @@ whilst the miner is still running ('p' followed by 'e' followed by pool number) pool be still be disabled on restart if the config file is not changed. This option is NOT created when the 'Write config file' option is used ('s' followed by 'w'). +In a similar manner, a 'remove-pool' option is also available. This can be mix and matched +with the 'disable-pool' option. Using 'remove-pool' enables the json file to contain a +large number of pools, of which some could be automatically culled at start up. +This makes it easy to swap pools in and out of the runtime selection, without having a +large list of pools cluttering up the disaply. A 'restart' of the miner ('s' followed by 'c') +will reload the config file and any changes the may have been made. + + "pools" : [ + { + "poolname" : "Main Pool", + "url" : "poola:porta", + "user" : "usernamea", + "pass" : "passa", + "disable-pool" : "0" + }, + { + "poolname" : "Joe's Weekend Pool" + "quota" : "2;poolb:portb", + "user" : "usernameb", + "pass" : "passb", + "remove-pool" : "1" + } + ] + ## Logging sgminer will log to stderr if it detects stderr is being redirected to a