Start mining as soon as any pool is found active and rely on the watchpool thread to bring up other pools.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
diff --git a/cgminer.c b/cgminer.c
index dcbc670..d8c4721 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4056,12 +4056,12 @@ void enable_device(struct cgpu_info *cgpu)
int main (int argc, char *argv[])
{
- unsigned int i, pools_active = 0;
- unsigned int j, k;
struct block *block, *tmpblock;
struct work *work, *tmpwork;
+ bool pools_active = false;
struct sigaction handler;
struct thr_info *thr;
+ unsigned int i, j, k;
/* This dangerous functions tramples random dynamically allocated
* variables so do it before anything at all */
@@ -4318,50 +4318,54 @@ int main (int argc, char *argv[])
/* We use the getq mutex as the staged lock */
stgd_lock = &getq->mutex;
-retry_pools:
- /* Test each pool to see if we can retrieve and use work and for what
- * it supports */
for (i = 0; i < total_pools; i++) {
- struct pool *pool;
+ struct pool *pool = pools[i];
- pool = pools[i];
pool->enabled = true;
- if (pool_active(pool, false)) {
- if (!currentpool)
- currentpool = pool;
- applog(LOG_INFO, "Pool %d %s active", pool->pool_no, pool->rpc_url);
- pools_active++;
- } else {
- if (pool == currentpool)
- currentpool = NULL;
- applog(LOG_WARNING, "Unable to get work from pool %d %s", pool->pool_no, pool->rpc_url);
- pool->idle = true;
- }
+ pool->idle = true;
}
- if (!pools_active) {
- if (use_curses)
- enable_curses();
- applog(LOG_ERR, "No servers were found that could be used to get work from.");
- applog(LOG_ERR, "Please check the details from the list below of the servers you have input");
- applog(LOG_ERR, "Most likely you have input the wrong URL, forgotten to add a port, or have not set up workers");
+ applog(LOG_NOTICE, "Probing for an alive pool");
+ do {
+ /* Look for at least one active pool before starting */
for (i = 0; i < total_pools; i++) {
- struct pool *pool;
-
- pool = pools[i];
- applog(LOG_WARNING, "Pool: %d URL: %s User: %s Password: %s",
- i, pool->rpc_url, pool->rpc_user, pool->rpc_pass);
+ struct pool *pool = pools[i];
+ if (pool_active(pool, false)) {
+ if (!currentpool)
+ currentpool = pool;
+ applog(LOG_INFO, "Pool %d %s active", pool->pool_no, pool->rpc_url);
+ 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 (use_curses) {
- halfdelay(150);
- applog(LOG_ERR, "Press any key to exit, or cgminer will try again in 15s.");
- if (getch() != ERR)
+
+ if (!pools_active) {
+ if (use_curses)
+ enable_curses();
+ applog(LOG_ERR, "No servers were found that could be used to get work from.");
+ applog(LOG_ERR, "Please check the details from the list below of the servers you have input");
+ applog(LOG_ERR, "Most likely you have input the wrong URL, forgotten to add a port, or have not set up workers");
+ for (i = 0; i < total_pools; i++) {
+ struct pool *pool;
+
+ pool = pools[i];
+ applog(LOG_WARNING, "Pool: %d URL: %s User: %s Password: %s",
+ i, pool->rpc_url, pool->rpc_user, pool->rpc_pass);
+ }
+ if (use_curses) {
+ halfdelay(150);
+ applog(LOG_ERR, "Press any key to exit, or cgminer will try again in 15s.");
+ if (getch() != ERR)
+ quit(0, "No servers could be used! Exiting.");
+ nocbreak();
+ } else
quit(0, "No servers could be used! Exiting.");
- nocbreak();
- } else
- quit(0, "No servers could be used! Exiting.");
- goto retry_pools;
- }
+ }
+ } while (!pools_active);
if (want_longpoll)
start_longpoll();