mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Only hand off to stratum from getwork if we succeed in initiating the protocol.
This commit is contained in:
parent
8893f7ab23
commit
7a01578cc5
23
cgminer.c
23
cgminer.c
@ -4206,6 +4206,18 @@ static void init_stratum_thread(struct pool *pool)
|
|||||||
|
|
||||||
static void *longpoll_thread(void *userdata);
|
static void *longpoll_thread(void *userdata);
|
||||||
|
|
||||||
|
static bool stratum_works(struct pool *pool)
|
||||||
|
{
|
||||||
|
applog(LOG_INFO, "Testing pool %d stratum %s", pool->pool_no, pool->stratum_url);
|
||||||
|
if (!extract_sockaddr(pool, pool->stratum_url))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!initiate_stratum(pool))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool pool_active(struct pool *pool, bool pinging)
|
static bool pool_active(struct pool *pool, bool pinging)
|
||||||
{
|
{
|
||||||
struct timeval tv_getwork, tv_getwork_reply;
|
struct timeval tv_getwork, tv_getwork_reply;
|
||||||
@ -4244,18 +4256,13 @@ retry_stratum:
|
|||||||
gettimeofday(&tv_getwork_reply, NULL);
|
gettimeofday(&tv_getwork_reply, NULL);
|
||||||
|
|
||||||
/* 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. Currently no
|
* and if so, switch to that in preference to getwork if it works */
|
||||||
* proxy support so don't try to switch if a proxy is in use. */
|
if (pool->stratum_url && stratum_works(pool)) {
|
||||||
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->stratum_url will be set again in extract_sockaddr */
|
|
||||||
pool->stratum_url = NULL;
|
|
||||||
extract_sockaddr(pool, pool->rpc_url);
|
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
goto retry_stratum;
|
goto retry_stratum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val) {
|
if (val) {
|
||||||
|
3
util.c
3
util.c
@ -1309,7 +1309,8 @@ out:
|
|||||||
json_decref(val);
|
json_decref(val);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pool->stratum_url = pool->sockaddr_url;
|
if (!pool->stratum_url)
|
||||||
|
pool->stratum_url = pool->sockaddr_url;
|
||||||
pool->stratum_active = true;
|
pool->stratum_active = true;
|
||||||
pool->swork.diff = 1;
|
pool->swork.diff = 1;
|
||||||
if (opt_protocol) {
|
if (opt_protocol) {
|
||||||
|
Loading…
Reference in New Issue
Block a user