|
|
@ -14,15 +14,19 @@ |
|
|
|
#include "ckpool.h" |
|
|
|
#include "ckpool.h" |
|
|
|
#include "libckpool.h" |
|
|
|
#include "libckpool.h" |
|
|
|
#include "generator.h" |
|
|
|
#include "generator.h" |
|
|
|
|
|
|
|
#include "bitcoin.h" |
|
|
|
|
|
|
|
|
|
|
|
int generator(proc_instance_t *pi) |
|
|
|
int generator(proc_instance_t *pi) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ckpool_t *ckp = pi->ckp; |
|
|
|
ckpool_t *ckp = pi->ckp; |
|
|
|
char *userpass = NULL; |
|
|
|
char *userpass = NULL; |
|
|
|
|
|
|
|
gbtbase_t gbt; |
|
|
|
connsock_t cs; |
|
|
|
connsock_t cs; |
|
|
|
int ret = 0; |
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
|
|
memset(&cs, 0, sizeof(cs)); |
|
|
|
memset(&cs, 0, sizeof(cs)); |
|
|
|
|
|
|
|
memset(&gbt, 0, sizeof(gbt)); |
|
|
|
|
|
|
|
|
|
|
|
if (!ckp->btcdurl) |
|
|
|
if (!ckp->btcdurl) |
|
|
|
ckp->btcdurl = strdup("localhost:8332"); |
|
|
|
ckp->btcdurl = strdup("localhost:8332"); |
|
|
|
if (!ckp->btcdauth) |
|
|
|
if (!ckp->btcdauth) |
|
|
@ -35,6 +39,7 @@ int generator(proc_instance_t *pi) |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
userpass = strdup(ckp->btcdauth); |
|
|
|
userpass = strdup(ckp->btcdauth); |
|
|
|
|
|
|
|
realloc_strcat(&userpass, ":"); |
|
|
|
realloc_strcat(&userpass, ckp->btcdpass); |
|
|
|
realloc_strcat(&userpass, ckp->btcdpass); |
|
|
|
cs.auth = http_base64(userpass); |
|
|
|
cs.auth = http_base64(userpass); |
|
|
|
if (!cs.auth) { |
|
|
|
if (!cs.auth) { |
|
|
@ -49,7 +54,16 @@ int generator(proc_instance_t *pi) |
|
|
|
ret = 1; |
|
|
|
ret = 1; |
|
|
|
goto out; |
|
|
|
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: |
|
|
|
out: |
|
|
|
/* Clean up here */ |
|
|
|
/* Clean up here */ |
|
|
|
dealloc(cs.url); |
|
|
|
dealloc(cs.url); |
|
|
|