Use stratum block change from backup pools as an alternative to longpoll for pools that don't support LP.
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
diff --git a/cgminer.c b/cgminer.c
index 129e261..1ae46e5 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -5686,7 +5686,7 @@ static struct pool *select_longpoll_pool(struct pool *cp)
for (i = 0; i < total_pools; i++) {
struct pool *pool = pools[i];
- if (pool->hdr_path)
+ if (pool->has_stratum || pool->hdr_path)
return pool;
}
return NULL;
@@ -5723,19 +5723,25 @@ static void *longpoll_thread(void *userdata)
curl = curl_easy_init();
if (unlikely(!curl)) {
applog(LOG_ERR, "CURL initialisation failed");
- goto out;
+ return NULL;
}
retry_pool:
pool = select_longpoll_pool(cp);
if (!pool) {
- applog(LOG_WARNING, "No suitable long-poll found for pool %s", cp->rpc_url);
+ applog(LOG_WARNING, "No suitable long-poll found for %s", cp->rpc_url);
while (!pool) {
sleep(60);
pool = select_longpoll_pool(cp);
}
}
+ if (pool->has_stratum) {
+ applog(LOG_WARNING, "Block change for %s detection via %s stratum",
+ cp->rpc_url, pool->rpc_url);
+ goto out;
+ }
+
/* Any longpoll from any pool is enough for this to be true */
have_longpoll = true;
@@ -5751,7 +5757,7 @@ retry_pool:
if (cp == pool)
applog(LOG_WARNING, "Long-polling activated for %s", lp_url);
else
- applog(LOG_WARNING, "Long-polling activated for pool %s via %s", cp->rpc_url, lp_url);
+ applog(LOG_WARNING, "Long-polling activated for %s via %s", cp->rpc_url, lp_url);
}
while (42) {
@@ -5802,8 +5808,14 @@ retry_pool:
applog(LOG_WARNING, "longpoll failed for %s, retrying every 30s", lp_url);
sleep(30);
}
+
if (pool != cp) {
pool = select_longpoll_pool(cp);
+ if (pool->has_stratum) {
+ applog(LOG_WARNING, "Block change for %s detection via %s stratum",
+ cp->rpc_url, pool->rpc_url);
+ break;
+ }
if (unlikely(!pool))
goto retry_pool;
}
@@ -5813,8 +5825,7 @@ retry_pool:
}
out:
- if (curl)
- curl_easy_cleanup(curl);
+ curl_easy_cleanup(curl);
return NULL;
}