mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 12:34:27 +00:00
Merge branch 'pools-joe'
This commit is contained in:
commit
e269656959
49
README.md
49
README.md
@ -333,6 +333,55 @@ 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').
|
||||
|
||||
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
|
||||
|
||||
|
2
miner.h
2
miner.h
@ -1182,8 +1182,10 @@ struct pool {
|
||||
bool idle;
|
||||
bool lagging;
|
||||
bool probed;
|
||||
bool start_disabled;
|
||||
enum pool_enable enabled;
|
||||
bool submit_old;
|
||||
bool remove_at_start;
|
||||
bool removed;
|
||||
bool lp_started;
|
||||
|
||||
|
99
sgminer.c
99
sgminer.c
@ -212,6 +212,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
|
||||
@ -742,6 +743,52 @@ 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 < 1)
|
||||
{
|
||||
disabled = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
disabled = atoi(arg);
|
||||
}
|
||||
pool->start_disabled = (disabled > 0);
|
||||
|
||||
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;
|
||||
@ -1025,6 +1072,12 @@ 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_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"),
|
||||
@ -1268,12 +1321,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;
|
||||
|
||||
@ -1309,7 +1364,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);
|
||||
@ -1374,7 +1432,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)
|
||||
@ -2053,8 +2111,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",
|
||||
@ -4404,6 +4462,7 @@ static void display_pools(void)
|
||||
struct pool *pool;
|
||||
int selected, i;
|
||||
char input;
|
||||
char *disp_name;
|
||||
|
||||
opt_loginput = true;
|
||||
immedok(logwin, true);
|
||||
@ -4428,11 +4487,16 @@ updated:
|
||||
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:
|
||||
@ -7879,10 +7943,29 @@ 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];
|
||||
|
||||
enable_pool(pool);
|
||||
if (pool->start_disabled)
|
||||
{
|
||||
disable_pool(pool);
|
||||
}
|
||||
else
|
||||
{
|
||||
enable_pool(pool);
|
||||
}
|
||||
pool->idle = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user