|
@@ -192,11 +192,11 @@ unsigned int total_go, total_ro;
|
|
|
|
|
|
|
|
struct pool *pools[MAX_POOLS];
|
|
struct pool *pools[MAX_POOLS];
|
|
|
static struct pool *currentpool = NULL;
|
|
static struct pool *currentpool = NULL;
|
|
|
-enum pool_enable opt_pool_enabled = POOL_ENABLED;
|
|
|
|
|
|
|
+
|
|
|
int total_pools;
|
|
int total_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 = 0, total_users = 0, total_passes = 0, total_userpasses = 0;
|
|
|
|
|
|
|
+static int total_urls, total_users, total_passes, total_userpasses;
|
|
|
|
|
|
|
|
#ifndef HAVE_CURSES
|
|
#ifndef HAVE_CURSES
|
|
|
const
|
|
const
|
|
@@ -405,9 +405,6 @@ static struct pool *add_pool(void)
|
|
|
/* Make sure the pool doesn't think we've been idle since time 0 */
|
|
/* Make sure the pool doesn't think we've been idle since time 0 */
|
|
|
pool->tv_idle.tv_sec = ~0UL;
|
|
pool->tv_idle.tv_sec = ~0UL;
|
|
|
|
|
|
|
|
- pool->enabled = POOL_ENABLED;
|
|
|
|
|
- pool->idle = true;
|
|
|
|
|
-
|
|
|
|
|
return pool;
|
|
return pool;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -593,18 +590,6 @@ static char *set_userpass(const char *arg)
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static char *set_pool_disabled(enum pool_enable *pool_state)
|
|
|
|
|
-{
|
|
|
|
|
- struct pool *pool;
|
|
|
|
|
- *pool_state = POOL_DISABLED; // This (and opt_pool_enabled) does nothing. Here for compatability
|
|
|
|
|
-
|
|
|
|
|
- if (total_pools) {
|
|
|
|
|
- pool = pools[total_pools - 1];
|
|
|
|
|
- pool->enabled = POOL_DISABLED;
|
|
|
|
|
- }
|
|
|
|
|
- return NULL;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static char *enable_debug(bool *flag)
|
|
static char *enable_debug(bool *flag)
|
|
|
{
|
|
{
|
|
|
*flag = true;
|
|
*flag = true;
|
|
@@ -1001,9 +986,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_WITHOUT_ARG("--disable-pool",
|
|
|
|
|
- set_pool_disabled, &opt_pool_enabled,
|
|
|
|
|
- "Start with pool disabled."),
|
|
|
|
|
OPT_WITH_ARG("--pools",
|
|
OPT_WITH_ARG("--pools",
|
|
|
opt_set_bool, NULL, NULL, opt_hidden),
|
|
opt_set_bool, NULL, NULL, opt_hidden),
|
|
|
OPT_ENDTABLE
|
|
OPT_ENDTABLE
|
|
@@ -2712,24 +2694,15 @@ void remove_pool(struct pool *pool)
|
|
|
|
|
|
|
|
void write_config(FILE *fcfg)
|
|
void write_config(FILE *fcfg)
|
|
|
{
|
|
{
|
|
|
- int i = 0;
|
|
|
|
|
- int j = 0;
|
|
|
|
|
- char *s;
|
|
|
|
|
|
|
+ int i;
|
|
|
|
|
|
|
|
- /* Write pool values in priority order */
|
|
|
|
|
|
|
+ /* Write pool values */
|
|
|
fputs("{\n\"pools\" : [", fcfg);
|
|
fputs("{\n\"pools\" : [", fcfg);
|
|
|
- while((j < total_pools) && (i < total_pools)) {
|
|
|
|
|
- if(pools[i]->prio == j) {
|
|
|
|
|
- fprintf(fcfg, "\n\t{\n\t\t\"url\" : \"%s\",", pools[i]->rpc_url);
|
|
|
|
|
- fprintf(fcfg, "\n\t\t\"user\" : \"%s\",", pools[i]->rpc_user);
|
|
|
|
|
- fprintf(fcfg, "\n\t\t\"pass\" : \"%s\"", pools[i]->rpc_pass);
|
|
|
|
|
- s = (pools[i]->enabled == POOL_DISABLED) ? ",\n\t\t\"disable-pool\" : true\n\t}%s" : "\n\t}%s";
|
|
|
|
|
- fprintf(fcfg, s, (j < total_pools - 1) ? "," : "");
|
|
|
|
|
- j++;
|
|
|
|
|
- i=0;
|
|
|
|
|
- } else
|
|
|
|
|
- i++;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for(i = 0; i < total_pools; i++) {
|
|
|
|
|
+ fprintf(fcfg, "%s\n\t{\n\t\t\"url\" : \"%s\",", i > 0 ? "," : "", pools[i]->rpc_url);
|
|
|
|
|
+ fprintf(fcfg, "\n\t\t\"user\" : \"%s\",", pools[i]->rpc_user);
|
|
|
|
|
+ fprintf(fcfg, "\n\t\t\"pass\" : \"%s\"\n\t}", pools[i]->rpc_pass);
|
|
|
|
|
+ }
|
|
|
fputs("\n]\n", fcfg);
|
|
fputs("\n]\n", fcfg);
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENCL
|
|
#ifdef HAVE_OPENCL
|
|
@@ -5140,14 +5113,8 @@ int main(int argc, char *argv[])
|
|
|
quit(1, "Failed to find colon delimiter in userpass");
|
|
quit(1, "Failed to find colon delimiter in userpass");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- /* Set the currentpool to pool first enabled */
|
|
|
|
|
- for (i = 0; i < total_pools; i++) {
|
|
|
|
|
- currentpool = pools[i];
|
|
|
|
|
- if (currentpool->enabled == POOL_ENABLED)
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- if (i == total_pools)
|
|
|
|
|
- quit(1, "All pools disabled!");
|
|
|
|
|
|
|
+ /* Set the currentpool to pool 0 */
|
|
|
|
|
+ currentpool = pools[0];
|
|
|
|
|
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
if (use_syslog)
|
|
if (use_syslog)
|
|
@@ -5200,6 +5167,13 @@ int main(int argc, char *argv[])
|
|
|
if (opt_benchmark)
|
|
if (opt_benchmark)
|
|
|
goto begin_bench;
|
|
goto begin_bench;
|
|
|
|
|
|
|
|
|
|
+ for (i = 0; i < total_pools; i++) {
|
|
|
|
|
+ struct pool *pool = pools[i];
|
|
|
|
|
+
|
|
|
|
|
+ pool->enabled = POOL_ENABLED;
|
|
|
|
|
+ pool->idle = true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
applog(LOG_NOTICE, "Probing for an alive pool");
|
|
applog(LOG_NOTICE, "Probing for an alive pool");
|
|
|
do {
|
|
do {
|
|
|
/* Look for at least one active pool before starting */
|
|
/* Look for at least one active pool before starting */
|