|
|
|
@ -14,15 +14,19 @@
|
|
|
|
|
#include "ckpool.h" |
|
|
|
|
#include "libckpool.h" |
|
|
|
|
#include "generator.h" |
|
|
|
|
#include "bitcoin.h" |
|
|
|
|
|
|
|
|
|
int generator(proc_instance_t *pi) |
|
|
|
|
{ |
|
|
|
|
ckpool_t *ckp = pi->ckp; |
|
|
|
|
char *userpass = NULL; |
|
|
|
|
gbtbase_t gbt; |
|
|
|
|
connsock_t cs; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
memset(&cs, 0, sizeof(cs)); |
|
|
|
|
memset(&gbt, 0, sizeof(gbt)); |
|
|
|
|
|
|
|
|
|
if (!ckp->btcdurl) |
|
|
|
|
ckp->btcdurl = strdup("localhost:8332"); |
|
|
|
|
if (!ckp->btcdauth) |
|
|
|
@ -35,6 +39,7 @@ int generator(proc_instance_t *pi)
|
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
userpass = strdup(ckp->btcdauth); |
|
|
|
|
realloc_strcat(&userpass, ":"); |
|
|
|
|
realloc_strcat(&userpass, ckp->btcdpass); |
|
|
|
|
cs.auth = http_base64(userpass); |
|
|
|
|
if (!cs.auth) { |
|
|
|
@ -49,7 +54,16 @@ int generator(proc_instance_t *pi)
|
|
|
|
|
ret = 1; |
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
keep_sockalive(cs.fd); |
|
|
|
|
block_socket(cs.fd); |
|
|
|
|
|
|
|
|
|
/* Test we can connect, authorise and get a block template */ |
|
|
|
|
if (!gen_gbtbase(&cs, &gbt)) { |
|
|
|
|
LOGWARNING("Failed to get test block template from %s:%s auth %s", |
|
|
|
|
cs.url, cs.port, userpass); |
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
clear_gbtbase(&gbt); |
|
|
|
|
out: |
|
|
|
|
/* Clean up here */ |
|
|
|
|
dealloc(cs.url); |
|
|
|
|