Browse Source

config: rename --pool-priority to --priority, --coin to --description.

There are now get_current_pool() and current_pool(), which is confusing.
Moved them closer together, so it's at least obvious.
refactor
Noel Maersk 11 years ago
parent
commit
b6218e20c1
  1. 5
      NEWS.md
  2. 2
      api.c
  3. 2
      miner.h
  4. 48
      sgminer.c

5
NEWS.md

@ -11,8 +11,9 @@
* Configuration parameter `poolname` has been renamed to `name`. * Configuration parameter `poolname` has been renamed to `name`.
`poolname` is deprecated and will be removed in a future version. `poolname` is deprecated and will be removed in a future version.
* Multiple `--name` parsing should now work as expected (by _troky_). * Multiple `--name` parsing should now work as expected (by _troky_).
* `--coin` configuration parameter to specify a freeform pool * `--description` configuration parameter to specify a freeform pool
description (by _troky_). description, and `--priority` to specify the pool's priority (by
_troky_).
## Version 4.1.153 - 14th March 2014 ## Version 4.1.153 - 14th March 2014

2
api.c

@ -1819,8 +1819,8 @@ static void poolstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
root = api_add_int(root, "POOL", &i, false); root = api_add_int(root, "POOL", &i, false);
root = api_add_string(root, "Name", pool->name, false); root = api_add_string(root, "Name", pool->name, false);
root = api_add_string(root, "Coin", pool->coin, false);
root = api_add_escape(root, "URL", pool->rpc_url, false); root = api_add_escape(root, "URL", pool->rpc_url, false);
root = api_add_string(root, "Description", pool->description, false);
root = api_add_string(root, "Status", status, false); root = api_add_string(root, "Status", status, false);
root = api_add_int(root, "Priority", &(pool->prio), false); root = api_add_int(root, "Priority", &(pool->prio), false);
root = api_add_int(root, "Quota", &pool->quota, false); root = api_add_int(root, "Quota", &pool->quota, false);

2
miner.h

@ -1172,7 +1172,7 @@ struct stratum_work {
struct pool { struct pool {
int pool_no; int pool_no;
char *name; char *name;
char *coin; char *description;
int prio; int prio;
int accepted, rejected; int accepted, rejected;
int seq_rejects; int seq_rejects;

48
sgminer.c

@ -230,6 +230,8 @@ int total_pools, enabled_pools;
enum pool_strategy pool_strategy = POOL_FAILOVER; enum pool_strategy pool_strategy = POOL_FAILOVER;
int opt_rotate_period; int opt_rotate_period;
static int total_urls; static int total_urls;
/* Used in config parsing, e.g. pool array. */
static int json_array_index = -1; static int json_array_index = -1;
static static
@ -554,11 +556,12 @@ struct pool *add_pool(void)
pool->quota = 1; pool->quota = 1;
adjust_quota_gcd(); adjust_quota_gcd();
pool->coin = ""; pool->description = "";
return pool; return pool;
} }
/* Used in configuration parsing. */
static struct pool* get_current_pool() static struct pool* get_current_pool()
{ {
while ((json_array_index + 1) > total_pools) while ((json_array_index + 1) > total_pools)
@ -573,6 +576,18 @@ static struct pool* get_current_pool()
return pools[json_array_index]; return pools[json_array_index];
} }
/* Used everywhere else. */
struct pool *current_pool(void)
{
struct pool *pool;
cg_rlock(&control_lock);
pool = currentpool;
cg_runlock(&control_lock);
return pool;
}
/* Pool variant of test and set */ /* Pool variant of test and set */
static bool pool_tset(struct pool *pool, bool *var) static bool pool_tset(struct pool *pool, bool *var)
{ {
@ -598,17 +613,6 @@ bool pool_tclear(struct pool *pool, bool *var)
return ret; return ret;
} }
struct pool *current_pool(void)
{
struct pool *pool;
cg_rlock(&control_lock);
pool = currentpool;
cg_runlock(&control_lock);
return pool;
}
char *set_int_range(const char *arg, int *i, int min, int max) char *set_int_range(const char *arg, int *i, int min, int max)
{ {
char *err = opt_set_intval(arg, i); char *err = opt_set_intval(arg, i);
@ -927,12 +931,12 @@ static char *set_pool_priority(char *arg)
return NULL; return NULL;
} }
static char *set_pool_coin(char *arg) static char *set_pool_description(char *arg)
{ {
struct pool *pool = get_current_pool(); struct pool *pool = get_current_pool();
applog(LOG_DEBUG, "Setting pool %i coin to %s", pool->pool_no, arg); applog(LOG_DEBUG, "Setting pool %i description to %s", pool->pool_no, arg);
opt_set_charp(arg, &pool->coin); opt_set_charp(arg, &pool->description);
return NULL; return NULL;
} }
@ -1144,9 +1148,6 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--benchmark", OPT_WITHOUT_ARG("--benchmark",
opt_set_bool, &opt_benchmark, opt_set_bool, &opt_benchmark,
"Run sgminer in benchmark mode - produces no shares"), "Run sgminer in benchmark mode - produces no shares"),
OPT_WITH_ARG("--coin",
set_pool_coin, NULL, NULL,
"Pool coin"),
#ifdef HAVE_CURSES #ifdef HAVE_CURSES
OPT_WITHOUT_ARG("--compact", OPT_WITHOUT_ARG("--compact",
opt_set_bool, &opt_compact, opt_set_bool, &opt_compact,
@ -1155,6 +1156,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--debug|-D", OPT_WITHOUT_ARG("--debug|-D",
enable_debug, &opt_debug, enable_debug, &opt_debug,
"Enable debug output"), "Enable debug output"),
OPT_WITH_ARG("--description",
set_pool_description, NULL, NULL,
"Pool description"),
OPT_WITH_ARG("--device|-d", OPT_WITH_ARG("--device|-d",
set_devices, NULL, NULL, set_devices, NULL, NULL,
"Select device to use, one value, range and/or comma separated (e.g. 0-2,4) default: all"), "Select device to use, one value, range and/or comma separated (e.g. 0-2,4) default: all"),
@ -1292,9 +1296,12 @@ static struct opt_table opt_config_table[] = {
OPT_WITHOUT_ARG("--per-device-stats", OPT_WITHOUT_ARG("--per-device-stats",
opt_set_bool, &want_per_device_stats, opt_set_bool, &want_per_device_stats,
"Force verbose mode and output per-device statistics"), "Force verbose mode and output per-device statistics"),
OPT_WITH_ARG("--poolname", /* Backward compatibility, to be removed. */ OPT_WITH_ARG("--poolname", /* TODO: Backward compatibility, to be removed. */
set_poolname_deprecated, NULL, NULL, set_poolname_deprecated, NULL, NULL,
opt_hidden), opt_hidden),
OPT_WITH_ARG("--priority",
set_pool_priority, NULL, NULL,
"Pool priority"),
OPT_WITHOUT_ARG("--protocol-dump|-P", OPT_WITHOUT_ARG("--protocol-dump|-P",
opt_set_bool, &opt_protocol, opt_set_bool, &opt_protocol,
"Verbose dump of protocol-level activities"), "Verbose dump of protocol-level activities"),
@ -1409,9 +1416,6 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--userpass|-O", OPT_WITH_ARG("--userpass|-O",
set_userpass, NULL, NULL, set_userpass, NULL, NULL,
"Username:Password pair for bitcoin JSON-RPC server"), "Username:Password pair for bitcoin JSON-RPC server"),
OPT_WITH_ARG("--pool-priority",
set_pool_priority, NULL, NULL,
"Pool priority"),
OPT_WITHOUT_ARG("--worktime", OPT_WITHOUT_ARG("--worktime",
opt_set_bool, &opt_worktime, opt_set_bool, &opt_worktime,
"Display extra work time debug information"), "Display extra work time debug information"),

Loading…
Cancel
Save