mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
Modify cgminer.c pool control to allow API to call it
This commit is contained in:
parent
6f65599ab7
commit
4458f3d5c7
64
cgminer.c
64
cgminer.c
@ -2272,7 +2272,7 @@ int curses_int(const char *query)
|
|||||||
|
|
||||||
static bool input_pool(bool live);
|
static bool input_pool(bool live);
|
||||||
|
|
||||||
static int active_pools(void)
|
int active_pools(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
@ -4051,10 +4051,43 @@ char *curses_input(const char *query)
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int add_pool_details(bool live, char *url, char *user, char *pass)
|
||||||
|
{
|
||||||
|
struct pool *pool = NULL;
|
||||||
|
|
||||||
|
if (total_pools == MAX_POOLS)
|
||||||
|
return ADD_POOL_MAXIMUM;
|
||||||
|
|
||||||
|
pool = calloc(sizeof(struct pool), 1);
|
||||||
|
if (!pool)
|
||||||
|
quit(1, "Failed to realloc pools in add_pool_details");
|
||||||
|
pool->pool_no = total_pools;
|
||||||
|
pool->prio = total_pools;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* Test the pool is not idle if we're live running, otherwise
|
||||||
|
* it will be tested separately */
|
||||||
|
pool->enabled = true;
|
||||||
|
if (live && !pool_active(pool, false))
|
||||||
|
pool->idle = true;
|
||||||
|
pools[total_pools++] = pool;
|
||||||
|
|
||||||
|
return ADD_POOL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static bool input_pool(bool live)
|
static bool input_pool(bool live)
|
||||||
{
|
{
|
||||||
char *url = NULL, *user = NULL, *pass = NULL;
|
char *url = NULL, *user = NULL, *pass = NULL;
|
||||||
struct pool *pool = NULL;
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
immedok(logwin, true);
|
immedok(logwin, true);
|
||||||
@ -4089,30 +4122,7 @@ static bool input_pool(bool live)
|
|||||||
if (!pass)
|
if (!pass)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
pool = calloc(sizeof(struct pool), 1);
|
ret = (add_pool_details(live, url, user, pass) == ADD_POOL_OK);
|
||||||
if (!pool)
|
|
||||||
quit(1, "Failed to realloc pools in input_pool");
|
|
||||||
pool->pool_no = total_pools;
|
|
||||||
pool->prio = total_pools;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/* Test the pool is not idle if we're live running, otherwise
|
|
||||||
* it will be tested separately */
|
|
||||||
ret = true;
|
|
||||||
pool->enabled = true;
|
|
||||||
if (live && !pool_active(pool, false))
|
|
||||||
pool->idle = true;
|
|
||||||
pools[total_pools++] = pool;
|
|
||||||
out:
|
out:
|
||||||
immedok(logwin, false);
|
immedok(logwin, false);
|
||||||
|
|
||||||
@ -4123,8 +4133,6 @@ out:
|
|||||||
free(user);
|
free(user);
|
||||||
if (pass)
|
if (pass)
|
||||||
free(pass);
|
free(pass);
|
||||||
if (pool)
|
|
||||||
free(pool);
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
6
miner.h
6
miner.h
@ -465,6 +465,12 @@ extern int set_memoryclock(int gpu, int iMemoryClock);
|
|||||||
|
|
||||||
extern void api(int thr_id);
|
extern void api(int thr_id);
|
||||||
|
|
||||||
|
extern int active_pools(void);
|
||||||
|
extern int add_pool_details(bool live, char *url, char *user, char *pass);
|
||||||
|
|
||||||
|
#define ADD_POOL_MAXIMUM 1
|
||||||
|
#define ADD_POOL_OK 0
|
||||||
|
|
||||||
#define MAX_GPUDEVICES 16
|
#define MAX_GPUDEVICES 16
|
||||||
#define MAX_DEVICES 32
|
#define MAX_DEVICES 32
|
||||||
#define MAX_POOLS (32)
|
#define MAX_POOLS (32)
|
||||||
|
Loading…
Reference in New Issue
Block a user