Add a temporarily disabled state for enabled pools called POOL_REJECTING and use the work from each longpoll to help determine when a rejecting pool has started working again. Switch pools based on the multipool strategy once a pool is re-enabled.
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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
diff --git a/cgminer.c b/cgminer.c
index db8a033..b2bcd5a 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1676,6 +1676,16 @@ static bool submit_upstream_work(const struct work *work, CURL *curl)
kill_work();
goto out;
}
+
+ /* Detect if a pool that has been temporarily disabled for
+ * continually rejecting shares has started accepting shares.
+ * This will only happen with the work returned from a
+ * longpoll */
+ if (unlikely(pool->enabled == POOL_REJECTING)) {
+ applog(LOG_WARNING, "Rejecting pool %d now accepting shares, re-enabling!", pool->pool_no);
+ pool->enabled = POOL_ENABLED;
+ switch_pools(NULL);
+ }
} else {
cgpu->rejected++;
total_rejected++;
@@ -1722,7 +1732,7 @@ static bool submit_upstream_work(const struct work *work, CURL *curl)
if (pool->seq_rejects > utility) {
applog(LOG_WARNING, "Pool %d rejected %d sequential shares, disabling!",
pool->pool_no, pool->seq_rejects);
- pool->enabled = false;
+ pool->enabled = POOL_REJECTING;
if (pool == current_pool())
switch_pools(NULL);
pool->seq_rejects = 0;
@@ -1770,7 +1780,7 @@ static inline struct pool *select_pool(bool lagging)
if (++rotating_pool >= total_pools)
rotating_pool = 0;
pool = pools[rotating_pool];
- if ((!pool->idle && pool->enabled) || pool == cp)
+ if ((!pool->idle && pool->enabled == POOL_ENABLED) || pool == cp)
break;
pool = NULL;
}
@@ -2102,6 +2112,7 @@ static bool workio_get_work(struct workio_cmd *wc)
static bool stale_work(struct work *work, bool share)
{
struct timeval now;
+ struct pool *pool;
if (opt_benchmark)
return false;
@@ -2116,7 +2127,8 @@ static bool stale_work(struct work *work, bool share)
if (work->work_block != work_block)
return true;
- if (opt_fail_only && !share && work->pool != current_pool())
+ pool = work->pool;
+ if (opt_fail_only && !share && pool != current_pool() && pool->enabled != POOL_REJECTING)
return true;
return false;
@@ -2241,7 +2253,7 @@ void switch_pools(struct pool *selected)
case POOL_LOADBALANCE:
for (i = 0; i < total_pools; i++) {
pool = priority_pool(i);
- if (!pool->idle && pool->enabled) {
+ if (!pool->idle && pool->enabled == POOL_ENABLED) {
pool_no = pool->pool_no;
break;
}
@@ -2550,7 +2562,7 @@ int active_pools(void)
int i;
for (i = 0; i < total_pools; i++) {
- if ((pools[i])->enabled)
+ if ((pools[i])->enabled == POOL_ENABLED)
ret++;
}
return ret;
@@ -2772,11 +2784,21 @@ updated:
if (pool == current_pool())
wattron(logwin, A_BOLD);
- if (!pool->enabled)
+ if (pool->enabled != POOL_ENABLED)
wattron(logwin, A_DIM);
- wlogprint("%d: %s %s Priority %d: %s User:%s\n",
- pool->pool_no,
- pool->enabled? "Enabled" : "Disabled",
+ wlogprint("%d: ");
+ switch (pool->enabled) {
+ case POOL_ENABLED:
+ wlogprint("Enabled ");
+ break;
+ case POOL_DISABLED:
+ wlogprint("Disabled ");
+ break;
+ case POOL_REJECTING:
+ wlogprint("Rejecting ");
+ break;
+ }
+ wlogprint("%s Priority %d: %s User:%s\n",
pool->idle? "Dead" : "Alive",
pool->prio,
pool->rpc_url, pool->rpc_user);
@@ -2812,7 +2834,7 @@ retry:
wlogprint("Unable to remove pool due to activity\n");
goto retry;
}
- pool->enabled = false;
+ pool->enabled = POOL_DISABLED;
remove_pool(pool);
goto updated;
} else if (!strncasecmp(&input, "s", 1)) {
@@ -2822,7 +2844,7 @@ retry:
goto retry;
}
pool = pools[selected];
- pool->enabled = true;
+ pool->enabled = POOL_ENABLED;
switch_pools(pool);
goto updated;
} else if (!strncasecmp(&input, "d", 1)) {
@@ -2836,7 +2858,7 @@ retry:
goto retry;
}
pool = pools[selected];
- pool->enabled = false;
+ pool->enabled = POOL_DISABLED;
if (pool == current_pool())
switch_pools(NULL);
goto updated;
@@ -2847,7 +2869,7 @@ retry:
goto retry;
}
pool = pools[selected];
- pool->enabled = true;
+ pool->enabled = POOL_ENABLED;
if (pool->prio < current_pool()->prio)
switch_pools(pool);
goto updated;
@@ -3888,8 +3910,11 @@ static void convert_to_work(json_t *val, bool rolltime, struct pool *pool)
* allows testwork to know whether LP discovered the block or not. */
test_work_current(work);
- /* Don't use backup LPs as work if we have failover-only enabled */
- if (pool != current_pool() && opt_fail_only) {
+ /* Don't use backup LPs as work if we have failover-only enabled. Use
+ * the longpoll work from a pool that has been rejecting shares as a
+ * way to detect when the pool has recovered.
+ */
+ if (pool != current_pool() && opt_fail_only && pool->enabled != POOL_REJECTING) {
free_work(work);
return;
}
@@ -4068,7 +4093,7 @@ static void *watchpool_thread(void __maybe_unused *userdata)
if (!opt_benchmark)
reap_curl(pool);
- if (!pool->enabled)
+ if (pool->enabled != POOL_ENABLED)
continue;
/* Test pool is idle once every minute */
@@ -4417,7 +4442,7 @@ int add_pool_details(bool live, char *url, char *user, char *pass)
/* Test the pool is not idle if we're live running, otherwise
* it will be tested separately */
- pool->enabled = true;
+ pool->enabled = POOL_ENABLED;
if (live && !pool_active(pool, false))
pool->idle = true;
@@ -4737,7 +4762,7 @@ int main(int argc, char *argv[])
strcpy(pool->rpc_url, "Benchmark");
pool->rpc_user = pool->rpc_url;
pool->rpc_pass = pool->rpc_url;
- pool->enabled = true;
+ pool->enabled = POOL_ENABLED;
pool->idle = false;
successful_connect = true;
}
@@ -4966,7 +4991,7 @@ int main(int argc, char *argv[])
for (i = 0; i < total_pools; i++) {
struct pool *pool = pools[i];
- pool->enabled = true;
+ pool->enabled = POOL_ENABLED;
pool->idle = true;
}
diff --git a/miner.h b/miner.h
index 4115cc5..a965ecc 100644
--- a/miner.h
+++ b/miner.h
@@ -604,6 +604,12 @@ struct curl_ent {
struct timeval tv;
};
+enum pool_enable {
+ POOL_ENABLED,
+ POOL_DISABLED,
+ POOL_REJECTING,
+};
+
struct pool {
int pool_no;
int prio;
@@ -614,7 +620,7 @@ struct pool {
bool idle;
bool lagging;
bool probed;
- bool enabled;
+ enum pool_enable enabled;
bool submit_old;
bool removed;
bool lp_started;