mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-28 15:34:16 +00:00
Make input pool capable of bringing up pools while running.
This commit is contained in:
parent
7841486f83
commit
20336ea15d
65
main.c
65
main.c
@ -1352,6 +1352,7 @@ static void display_pools(void)
|
|||||||
pthread_mutex_unlock(&curses_lock);
|
pthread_mutex_unlock(&curses_lock);
|
||||||
i = getch();
|
i = getch();
|
||||||
opt_loginput = false;
|
opt_loginput = false;
|
||||||
|
clear_logwin();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *input_thread(void *userdata)
|
static void *input_thread(void *userdata)
|
||||||
@ -1564,7 +1565,7 @@ static bool pool_active(struct pool *pool)
|
|||||||
}
|
}
|
||||||
rc = work_decode(json_object_get(val, "result"), work);
|
rc = work_decode(json_object_get(val, "result"), work);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
applog(LOG_DEBUG, "Successfully retreived and deciphered work from pool %u %s",
|
applog(LOG_DEBUG, "Successfully retrieved and deciphered work from pool %u %s",
|
||||||
pool->pool_no, pool->rpc_url);
|
pool->pool_no, pool->rpc_url);
|
||||||
work->pool = pool;
|
work->pool = pool;
|
||||||
tq_push(thr_info[stage_thr_id].q, work);
|
tq_push(thr_info[stage_thr_id].q, work);
|
||||||
@ -2654,32 +2655,65 @@ static char *curses_input(const char *query)
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void input_pool(void)
|
static bool input_pool(bool live)
|
||||||
{
|
{
|
||||||
char *url, *user, *pass, *seterr;
|
char *url, *user, *pass;
|
||||||
|
int poolno = total_pools;
|
||||||
|
struct pool *pool;
|
||||||
|
|
||||||
echo();
|
echo();
|
||||||
immedok(logwin, true);
|
immedok(logwin, true);
|
||||||
wprintw(logwin, "Input server details.\n");
|
wprintw(logwin, "Input server details.\n");
|
||||||
|
|
||||||
url = curses_input("URL");
|
url = curses_input("URL");
|
||||||
seterr = set_url(url, NULL);
|
if (strncmp(url, "http://", 7) &&
|
||||||
if (seterr)
|
strncmp(url, "https://", 8)) {
|
||||||
quit(1, "%s", seterr);
|
applog(LOG_ERR, "URL must start with http:// or https://");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
user = curses_input("Username");
|
user = curses_input("Username");
|
||||||
seterr = set_user(user, NULL);
|
if (!user)
|
||||||
if (seterr)
|
return false;
|
||||||
quit(1, "%s", seterr);
|
|
||||||
|
|
||||||
pass = curses_input("Password");
|
pass = curses_input("Password");
|
||||||
seterr = set_pass(pass, NULL);
|
if (!pass)
|
||||||
if (seterr)
|
return false;
|
||||||
quit(1, "%s", seterr);
|
|
||||||
|
|
||||||
wclear(logwin);
|
wclear(logwin);
|
||||||
immedok(logwin, false);
|
immedok(logwin, false);
|
||||||
noecho();
|
noecho();
|
||||||
|
|
||||||
|
pools = realloc(pools, sizeof(struct pool) * (total_pools + 1));
|
||||||
|
if (!pools)
|
||||||
|
quit(1, "Failed to malloc pools in input_pool");
|
||||||
|
pool = &pools[poolno];
|
||||||
|
memset(pool, 0, sizeof(struct pool));
|
||||||
|
pool->pool_no = poolno;
|
||||||
|
if (unlikely(pthread_mutex_init(&pool->pool_lock, NULL)))
|
||||||
|
quit (1, "Failed to pthread_mutex_init in input_pool");
|
||||||
|
pool->rpc_url = url;
|
||||||
|
pool->rpc_user = user;
|
||||||
|
pool->rpc_pass = pass;
|
||||||
|
pool->rpc_userpass = malloc(strlen(pool->rpc_user) + strlen(pool->rpc_pass) + 2);
|
||||||
|
if (!pool->rpc_userpass)
|
||||||
|
quit(1, "Failed to malloc userpass");
|
||||||
|
sprintf(pool->rpc_userpass, "%s:%s", pool->rpc_user, pool->rpc_pass);
|
||||||
|
|
||||||
|
pool->tv_idle.tv_sec = ~0UL;
|
||||||
|
|
||||||
|
if (!live) {
|
||||||
|
total_pools++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test the pool before we enable it if we're live running*/
|
||||||
|
if (pool_active(pool)) {
|
||||||
|
pool->enabled = true;
|
||||||
|
total_pools++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
@ -2797,9 +2831,10 @@ int main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!total_pools) {
|
if (!total_pools) {
|
||||||
if (curses_active)
|
if (curses_active) {
|
||||||
input_pool();
|
if (!input_pool(false))
|
||||||
else
|
quit(1, "Pool setup failed");
|
||||||
|
} else
|
||||||
quit(1, "No server specified");
|
quit(1, "No server specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user