1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-11 15:27:53 +00:00

Use stratum block change from backup pools as an alternative to longpoll for pools that don't support LP.

This commit is contained in:
Con Kolivas 2012-11-11 20:53:27 +11:00
parent 38eb4ee43b
commit 89cb14199a

View File

@ -5686,7 +5686,7 @@ static struct pool *select_longpoll_pool(struct pool *cp)
for (i = 0; i < total_pools; i++) { for (i = 0; i < total_pools; i++) {
struct pool *pool = pools[i]; struct pool *pool = pools[i];
if (pool->hdr_path) if (pool->has_stratum || pool->hdr_path)
return pool; return pool;
} }
return NULL; return NULL;
@ -5723,19 +5723,25 @@ static void *longpoll_thread(void *userdata)
curl = curl_easy_init(); curl = curl_easy_init();
if (unlikely(!curl)) { if (unlikely(!curl)) {
applog(LOG_ERR, "CURL initialisation failed"); applog(LOG_ERR, "CURL initialisation failed");
goto out; return NULL;
} }
retry_pool: retry_pool:
pool = select_longpoll_pool(cp); pool = select_longpoll_pool(cp);
if (!pool) { 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) { while (!pool) {
sleep(60); sleep(60);
pool = select_longpoll_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);
goto out;
}
/* Any longpoll from any pool is enough for this to be true */ /* Any longpoll from any pool is enough for this to be true */
have_longpoll = true; have_longpoll = true;
@ -5751,7 +5757,7 @@ retry_pool:
if (cp == pool) if (cp == pool)
applog(LOG_WARNING, "Long-polling activated for %s", lp_url); applog(LOG_WARNING, "Long-polling activated for %s", lp_url);
else 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) { while (42) {
@ -5802,8 +5808,14 @@ retry_pool:
applog(LOG_WARNING, "longpoll failed for %s, retrying every 30s", lp_url); applog(LOG_WARNING, "longpoll failed for %s, retrying every 30s", lp_url);
sleep(30); sleep(30);
} }
if (pool != cp) { if (pool != cp) {
pool = select_longpoll_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)) if (unlikely(!pool))
goto retry_pool; goto retry_pool;
} }
@ -5813,7 +5825,6 @@ retry_pool:
} }
out: out:
if (curl)
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
return NULL; return NULL;