Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix client.reconnect #25

Open
wants to merge 3 commits into
base: Verus2.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ccminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ bool want_longpoll = false;
bool have_longpoll = false;
bool want_stratum = true;
bool have_stratum = false;
bool opt_redirect = true;
bool allow_gbt = true;
bool allow_mininginfo = true;
bool check_dups = false; //false;
Expand Down Expand Up @@ -336,6 +337,7 @@ Options:\n\
--no-gbt disable getblocktemplate support (height check in solo)\n\
--no-longpoll disable X-Long-Polling support\n\
--no-stratum disable X-Stratum support\n\
--no-redirect ignore requests to change the URL of the mining server\n\
--no-extranonce disable extranonce subscribe on stratum\n\
-q, --quiet disable per-thread hashmeter output\n\
--no-color disable colored output\n\
Expand Down Expand Up @@ -428,6 +430,7 @@ struct option options[] = {
{ "resume-diff", 1, NULL, 1063 },
{ "resume-rate", 1, NULL, 1064 },
{ "resume-temp", 1, NULL, 1065 },
{ "no-redirect", 0, NULL, 1066 },
{ "pass", 1, NULL, 'p' },
{ "pool-name", 1, NULL, 1100 }, // pool
{ "pool-algo", 1, NULL, 1101 }, // pool
Expand Down Expand Up @@ -2590,7 +2593,7 @@ static void *stratum_thread(void *userdata)
pthread_mutex_unlock(&g_work_lock);
restart_threads();

if (!stratum_connect(&stratum, pool->url) ||
if (!stratum_connect(&stratum, stratum.url) ||
!stratum_subscribe(&stratum) ||
!stratum_authorize(&stratum, pool->user, pool->pass))
{
Expand Down Expand Up @@ -3182,6 +3185,9 @@ void parse_arg(int key, char *arg)
d = atof(arg);
opt_resume_temp = d;
break;
case 1066: // no-redirect
opt_redirect = false;
break;
case 'd': // --device
{
int device_thr[MAX_GPUS] = { 0 };
Expand Down
1 change: 1 addition & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ extern bool want_longpoll;
extern bool have_longpoll;
extern bool want_stratum;
extern bool have_stratum;
extern bool opt_redirect;
extern bool opt_stratum_stats;
extern char *opt_cert;
extern char *opt_proxy;
Expand Down
18 changes: 13 additions & 5 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@ static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params)
static bool stratum_reconnect(struct stratum_ctx *sctx, json_t *params)
{
json_t *port_val;
char *url;
const char *host;
int port;

Expand All @@ -1593,13 +1594,20 @@ static bool stratum_reconnect(struct stratum_ctx *sctx, json_t *params)
port = (int) json_integer_value(port_val);
if (!host || !port)
return false;

free(sctx->url);
sctx->url = (char*)malloc(32 + strlen(host));
sprintf(sctx->url, "stratum+tcp://%s:%d", host, port);

applog(LOG_NOTICE, "Server requested reconnection to %s", sctx->url);
url = (char*)malloc(32 + strlen(host));
sprintf(url, "stratum+tcp://%s:%d", host, port);

if (!opt_redirect) {
applog(LOG_INFO, "Ignoring request to reconnect to %s", url);
free(url);
return true;
}

applog(LOG_NOTICE, "Server requested reconnection to %s", url);

free(sctx->url);
sctx->url = url;
stratum_disconnect(sctx);

return true;
Expand Down