mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 18:14:20 +00:00
Check all pools simultaneously at startup switching to the first alive one to speed up startup.
This commit is contained in:
parent
c9b4f5c757
commit
5221662557
60
cgminer.c
60
cgminer.c
@ -6922,9 +6922,43 @@ static void *hotplug_thread(void __maybe_unused *userdata)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool pools_active = false;
|
||||||
|
|
||||||
|
static void *test_pool_thread(void *arg)
|
||||||
|
{
|
||||||
|
struct pool *pool = (struct pool *)arg;
|
||||||
|
|
||||||
|
if (pool_active(pool, false)) {
|
||||||
|
pool_tset(pool, &pool->lagging);
|
||||||
|
pool_tclear(pool, &pool->idle);
|
||||||
|
applog(LOG_INFO, "Pool %d %s active", pool->pool_no, pool->rpc_url);
|
||||||
|
mutex_lock(&control_lock);
|
||||||
|
if (!pools_active) {
|
||||||
|
currentpool = pool;
|
||||||
|
if (pool->pool_no != 0)
|
||||||
|
applog(LOG_NOTICE, "Switching to pool %d %s - first alive pool", pool->pool_no, pool->rpc_url);
|
||||||
|
}
|
||||||
|
pools_active = true;
|
||||||
|
mutex_unlock(&control_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void probe_pools(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < total_pools; i++) {
|
||||||
|
pthread_t *test_thread = malloc(sizeof(pthread_t));
|
||||||
|
struct pool *pool = pools[i];
|
||||||
|
|
||||||
|
pthread_create(test_thread, NULL, test_pool_thread, (void *)pool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool pools_active = false;
|
|
||||||
struct sigaction handler;
|
struct sigaction handler;
|
||||||
struct thr_info *thr;
|
struct thr_info *thr;
|
||||||
struct block *block;
|
struct block *block;
|
||||||
@ -7299,24 +7333,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
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 */
|
int slept = 0;
|
||||||
for (i = 0; i < total_pools; i++) {
|
|
||||||
struct pool *pool = pools[i];
|
|
||||||
|
|
||||||
if (pool_active(pool, false)) {
|
/* Look for at least one active pool before starting */
|
||||||
pool_tset(pool, &pool->lagging);
|
probe_pools();
|
||||||
pool_tclear(pool, &pool->idle);
|
do {
|
||||||
if (!currentpool)
|
sleep(1);
|
||||||
currentpool = pool;
|
slept++;
|
||||||
applog(LOG_INFO, "Pool %d %s active", pool->pool_no, pool->rpc_url);
|
} while (!pools_active && slept < 60);
|
||||||
pools_active = true;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (pool == currentpool)
|
|
||||||
currentpool = NULL;
|
|
||||||
applog(LOG_WARNING, "Unable to get work from pool %d %s", pool->pool_no, pool->rpc_url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pools_active) {
|
if (!pools_active) {
|
||||||
applog(LOG_ERR, "No servers were found that could be used to get work from.");
|
applog(LOG_ERR, "No servers were found that could be used to get work from.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user