mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
Make extract_sockaddr set variables passed to it rather than pool struct members.
This commit is contained in:
parent
9282054987
commit
8ede407df7
@ -684,7 +684,7 @@ 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)
|
||||||
{
|
{
|
||||||
if (!extract_sockaddr(pool, url))
|
if (!extract_sockaddr(url, &pool->sockaddr_url, &pool->stratum_port))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!strncasecmp(url, "stratum+tcp://", 14)) {
|
if (!strncasecmp(url, "stratum+tcp://", 14)) {
|
||||||
@ -5329,7 +5329,7 @@ static void *longpoll_thread(void *userdata);
|
|||||||
static bool stratum_works(struct pool *pool)
|
static bool stratum_works(struct pool *pool)
|
||||||
{
|
{
|
||||||
applog(LOG_INFO, "Testing pool %d stratum %s", pool->pool_no, pool->stratum_url);
|
applog(LOG_INFO, "Testing pool %d stratum %s", pool->pool_no, pool->stratum_url);
|
||||||
if (!extract_sockaddr(pool, pool->stratum_url))
|
if (!extract_sockaddr(pool->stratum_url, &pool->sockaddr_url, &pool->stratum_port))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!initiate_stratum(pool))
|
if (!initiate_stratum(pool))
|
||||||
|
10
util.c
10
util.c
@ -1072,13 +1072,13 @@ double tdiff(struct timeval *end, struct timeval *start)
|
|||||||
return end->tv_sec - start->tv_sec + (end->tv_usec - start->tv_usec) / 1000000.0;
|
return end->tv_sec - start->tv_sec + (end->tv_usec - start->tv_usec) / 1000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool extract_sockaddr(struct pool *pool, char *url)
|
bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port)
|
||||||
{
|
{
|
||||||
char *url_begin, *url_end, *ipv6_begin, *ipv6_end, *port_start = NULL;
|
char *url_begin, *url_end, *ipv6_begin, *ipv6_end, *port_start = NULL;
|
||||||
char url_address[256], port[6];
|
char url_address[256], port[6];
|
||||||
int url_len, port_len = 0;
|
int url_len, port_len = 0;
|
||||||
|
|
||||||
pool->sockaddr_url = url;
|
*sockaddr_url = url;
|
||||||
url_begin = strstr(url, "//");
|
url_begin = strstr(url, "//");
|
||||||
if (!url_begin)
|
if (!url_begin)
|
||||||
url_begin = url;
|
url_begin = url;
|
||||||
@ -1111,8 +1111,8 @@ bool extract_sockaddr(struct pool *pool, char *url)
|
|||||||
else
|
else
|
||||||
strcpy(port, "80");
|
strcpy(port, "80");
|
||||||
|
|
||||||
pool->stratum_port = strdup(port);
|
*sockaddr_port = strdup(port);
|
||||||
pool->sockaddr_url = strdup(url_address);
|
*sockaddr_url = strdup(url_address);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1557,7 +1557,7 @@ static bool parse_reconnect(struct pool *pool, json_t *val)
|
|||||||
|
|
||||||
sprintf(address, "%s:%s", url, port);
|
sprintf(address, "%s:%s", url, port);
|
||||||
|
|
||||||
if (!extract_sockaddr(pool, address))
|
if (!extract_sockaddr(address, &pool->sockaddr_url, &pool->stratum_port))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pool->stratum_url = pool->sockaddr_url;
|
pool->stratum_url = pool->sockaddr_url;
|
||||||
|
2
util.h
2
util.h
@ -97,7 +97,7 @@ bool stratum_send(struct pool *pool, char *s, ssize_t len);
|
|||||||
bool sock_full(struct pool *pool);
|
bool sock_full(struct pool *pool);
|
||||||
char *recv_line(struct pool *pool);
|
char *recv_line(struct pool *pool);
|
||||||
bool parse_method(struct pool *pool, char *s);
|
bool parse_method(struct pool *pool, char *s);
|
||||||
bool extract_sockaddr(struct pool *pool, char *url);
|
bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port);
|
||||||
bool auth_stratum(struct pool *pool);
|
bool auth_stratum(struct pool *pool);
|
||||||
bool initiate_stratum(struct pool *pool);
|
bool initiate_stratum(struct pool *pool);
|
||||||
bool restart_stratum(struct pool *pool);
|
bool restart_stratum(struct pool *pool);
|
||||||
|
Loading…
Reference in New Issue
Block a user