|
|
@ -113,7 +113,7 @@ retry: |
|
|
|
server_instance_t *si; |
|
|
|
server_instance_t *si; |
|
|
|
char *userpass = NULL; |
|
|
|
char *userpass = NULL; |
|
|
|
connsock_t *cs; |
|
|
|
connsock_t *cs; |
|
|
|
gbtbase_t gbt; |
|
|
|
gbtbase_t *gbt; |
|
|
|
|
|
|
|
|
|
|
|
si = ckp->servers[i]; |
|
|
|
si = ckp->servers[i]; |
|
|
|
cs = &si->cs; |
|
|
|
cs = &si->cs; |
|
|
@ -140,13 +140,13 @@ retry: |
|
|
|
keep_sockalive(cs->fd); |
|
|
|
keep_sockalive(cs->fd); |
|
|
|
|
|
|
|
|
|
|
|
/* Test we can connect, authorise and get a block template */ |
|
|
|
/* Test we can connect, authorise and get a block template */ |
|
|
|
memset(&gbt, 0, sizeof(gbtbase_t)); |
|
|
|
gbt = si->data; |
|
|
|
if (!gen_gbtbase(cs, &gbt)) { |
|
|
|
if (!gen_gbtbase(cs, gbt)) { |
|
|
|
LOGINFO("Failed to get test block template from %s:%s auth %s !", |
|
|
|
LOGINFO("Failed to get test block template from %s:%s auth %s !", |
|
|
|
cs->url, cs->port, userpass); |
|
|
|
cs->url, cs->port, userpass); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
clear_gbtbase(&gbt); |
|
|
|
clear_gbtbase(gbt); |
|
|
|
if (!validate_address(cs, ckp->btcaddress)) { |
|
|
|
if (!validate_address(cs, ckp->btcaddress)) { |
|
|
|
LOGWARNING("Invalid btcaddress: %s !", ckp->btcaddress); |
|
|
|
LOGWARNING("Invalid btcaddress: %s !", ckp->btcaddress); |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -170,11 +170,11 @@ static int gen_loop(proc_instance_t *pi) |
|
|
|
int sockd, ret = 0; |
|
|
|
int sockd, ret = 0; |
|
|
|
char *buf = NULL; |
|
|
|
char *buf = NULL; |
|
|
|
connsock_t *cs; |
|
|
|
connsock_t *cs; |
|
|
|
gbtbase_t gbt; |
|
|
|
gbtbase_t *gbt; |
|
|
|
char hash[68]; |
|
|
|
char hash[68]; |
|
|
|
|
|
|
|
|
|
|
|
memset(&gbt, 0, sizeof(gbt)); |
|
|
|
|
|
|
|
si = live_server(ckp); |
|
|
|
si = live_server(ckp); |
|
|
|
|
|
|
|
gbt = si->data; |
|
|
|
cs = &si->cs; |
|
|
|
cs = &si->cs; |
|
|
|
retry: |
|
|
|
retry: |
|
|
|
sockd = accept(us->sockd, NULL, NULL); |
|
|
|
sockd = accept(us->sockd, NULL, NULL); |
|
|
@ -199,16 +199,16 @@ retry: |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!strncasecmp(buf, "getbase", 7)) { |
|
|
|
if (!strncasecmp(buf, "getbase", 7)) { |
|
|
|
if (!gen_gbtbase(cs, &gbt)) { |
|
|
|
if (!gen_gbtbase(cs, gbt)) { |
|
|
|
LOGWARNING("Failed to get block template from %s:%s", |
|
|
|
LOGWARNING("Failed to get block template from %s:%s", |
|
|
|
cs->url, cs->port); |
|
|
|
cs->url, cs->port); |
|
|
|
send_unix_msg(sockd, "Failed"); |
|
|
|
send_unix_msg(sockd, "Failed"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
char *s = json_dumps(gbt.json, 0); |
|
|
|
char *s = json_dumps(gbt->json, 0); |
|
|
|
|
|
|
|
|
|
|
|
send_unix_msg(sockd, s); |
|
|
|
send_unix_msg(sockd, s); |
|
|
|
free(s); |
|
|
|
free(s); |
|
|
|
clear_gbtbase(&gbt); |
|
|
|
clear_gbtbase(gbt); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (!strncasecmp(buf, "getbest", 7)) { |
|
|
|
} else if (!strncasecmp(buf, "getbest", 7)) { |
|
|
|
if (!get_bestblockhash(cs, hash)) { |
|
|
|
if (!get_bestblockhash(cs, hash)) { |
|
|
@ -1152,17 +1152,23 @@ static int server_mode(ckpool_t *ckp, proc_instance_t *pi) |
|
|
|
|
|
|
|
|
|
|
|
ckp->servers = ckalloc(sizeof(server_instance_t *) * ckp->btcds); |
|
|
|
ckp->servers = ckalloc(sizeof(server_instance_t *) * ckp->btcds); |
|
|
|
for (i = 0; i < ckp->btcds; i++) { |
|
|
|
for (i = 0; i < ckp->btcds; i++) { |
|
|
|
|
|
|
|
gbtbase_t *gbt; |
|
|
|
|
|
|
|
|
|
|
|
ckp->servers[i] = ckzalloc(sizeof(server_instance_t)); |
|
|
|
ckp->servers[i] = ckzalloc(sizeof(server_instance_t)); |
|
|
|
si = ckp->servers[i]; |
|
|
|
si = ckp->servers[i]; |
|
|
|
si->url = ckp->btcdurl[i]; |
|
|
|
si->url = ckp->btcdurl[i]; |
|
|
|
si->auth = ckp->btcdauth[i]; |
|
|
|
si->auth = ckp->btcdauth[i]; |
|
|
|
si->pass = ckp->btcdpass[i]; |
|
|
|
si->pass = ckp->btcdpass[i]; |
|
|
|
|
|
|
|
gbt = ckzalloc(sizeof(gbtbase_t)); |
|
|
|
|
|
|
|
si->data = gbt; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ret = gen_loop(pi); |
|
|
|
ret = gen_loop(pi); |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < ckp->btcds; si = ckp->servers[i], i++) |
|
|
|
for (i = 0; i < ckp->btcds; si = ckp->servers[i], i++) { |
|
|
|
|
|
|
|
dealloc(si->data); |
|
|
|
dealloc(si); |
|
|
|
dealloc(si); |
|
|
|
|
|
|
|
} |
|
|
|
dealloc(ckp->servers); |
|
|
|
dealloc(ckp->servers); |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|