mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Initiate stratum the first time in pool_active only, allowing us to switch to it on getting a failed getwork and detecting the presence of stratum on the url at that time.
This commit is contained in:
parent
d122a789ed
commit
1b7aa48c8f
18
cgminer.c
18
cgminer.c
@ -562,17 +562,12 @@ static char *set_rr(enum pool_strategy *strategy)
|
|||||||
* stratum+tcp or by detecting a stratum server response */
|
* stratum+tcp or by detecting a stratum server response */
|
||||||
bool detect_stratum(struct pool *pool, char *url)
|
bool detect_stratum(struct pool *pool, char *url)
|
||||||
{
|
{
|
||||||
bool stratum;
|
|
||||||
|
|
||||||
if (!extract_sockaddr(pool, url))
|
if (!extract_sockaddr(pool, url))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stratum = initiate_stratum(pool);
|
if (!strncasecmp(url, "stratum+tcp://", 14)) {
|
||||||
|
|
||||||
if (!strncasecmp(url, "stratum+tcp://", 14) || stratum) {
|
|
||||||
pool->has_stratum = true;
|
pool->has_stratum = true;
|
||||||
if (!pool->stratum_url)
|
pool->stratum_url = pool->sockaddr_url;
|
||||||
pool->stratum_url = pool->sockaddr_url;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4205,6 +4200,7 @@ static bool pool_active(struct pool *pool, bool pinging)
|
|||||||
|
|
||||||
applog(LOG_INFO, "Testing pool %s", pool->rpc_url);
|
applog(LOG_INFO, "Testing pool %s", pool->rpc_url);
|
||||||
|
|
||||||
|
/* This is the central point we activate stratum when we can */
|
||||||
retry_stratum:
|
retry_stratum:
|
||||||
if (pool->has_stratum) {
|
if (pool->has_stratum) {
|
||||||
if ((!pool->stratum_active || pinging) && !initiate_stratum(pool))
|
if ((!pool->stratum_active || pinging) && !initiate_stratum(pool))
|
||||||
@ -4233,7 +4229,7 @@ retry_stratum:
|
|||||||
|
|
||||||
/* Detect if a http getwork pool has an X-Stratum header at startup,
|
/* Detect if a http getwork pool has an X-Stratum header at startup,
|
||||||
* and if so, switch to that in preference to getwork */
|
* and if so, switch to that in preference to getwork */
|
||||||
if (unlikely(!pinging && pool->stratum_url)) {
|
if (unlikely(pool->stratum_url)) {
|
||||||
applog(LOG_NOTICE, "Switching pool %d %s to %s", pool->pool_no, pool->rpc_url, pool->stratum_url);
|
applog(LOG_NOTICE, "Switching pool %d %s to %s", pool->pool_no, pool->rpc_url, pool->stratum_url);
|
||||||
pool->has_stratum = true;
|
pool->has_stratum = true;
|
||||||
pool->rpc_url = pool->stratum_url;
|
pool->rpc_url = pool->stratum_url;
|
||||||
@ -4308,6 +4304,12 @@ retry_stratum:
|
|||||||
quit(1, "Failed to create pool longpoll thread");
|
quit(1, "Failed to create pool longpoll thread");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/* If we failed to parse a getwork, this could be a stratum
|
||||||
|
* url without the prefix stratum+tcp:// so let's check it */
|
||||||
|
if (initiate_stratum(pool)) {
|
||||||
|
pool->has_stratum = true;
|
||||||
|
goto retry_stratum;
|
||||||
|
}
|
||||||
applog(LOG_DEBUG, "FAILED to retrieve work from pool %u %s",
|
applog(LOG_DEBUG, "FAILED to retrieve work from pool %u %s",
|
||||||
pool->pool_no, pool->rpc_url);
|
pool->pool_no, pool->rpc_url);
|
||||||
if (!pinging)
|
if (!pinging)
|
||||||
|
2
util.c
2
util.c
@ -906,7 +906,7 @@ static bool sock_full(SOCKETTYPE sock, bool wait)
|
|||||||
FD_SET(sock, &rd);
|
FD_SET(sock, &rd);
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
if (wait)
|
if (wait)
|
||||||
timeout.tv_sec = 5;
|
timeout.tv_sec = 60;
|
||||||
else
|
else
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
if (select(sock + 1, &rd, NULL, NULL, &timeout) > 0)
|
if (select(sock + 1, &rd, NULL, NULL, &timeout) > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user