|
|
@ -159,7 +159,7 @@ static struct { |
|
|
|
|
|
|
|
|
|
|
|
static int64_t workbase_id; |
|
|
|
static int64_t workbase_id; |
|
|
|
static int64_t blockchange_id; |
|
|
|
static int64_t blockchange_id; |
|
|
|
static char lasthash[68]; |
|
|
|
static char lasthash[68], lastswaphash[68]; |
|
|
|
|
|
|
|
|
|
|
|
struct json_params { |
|
|
|
struct json_params { |
|
|
|
json_t *params; |
|
|
|
json_t *params; |
|
|
@ -556,10 +556,14 @@ static void add_base(ckpool_t *ckp, workbase_t *wb, bool *new_block) |
|
|
|
|
|
|
|
|
|
|
|
ck_wlock(&workbase_lock); |
|
|
|
ck_wlock(&workbase_lock); |
|
|
|
wb->id = workbase_id++; |
|
|
|
wb->id = workbase_id++; |
|
|
|
|
|
|
|
|
|
|
|
if (strncmp(wb->prevhash, lasthash, 64)) { |
|
|
|
if (strncmp(wb->prevhash, lasthash, 64)) { |
|
|
|
|
|
|
|
char bin[32], swap[32]; |
|
|
|
|
|
|
|
|
|
|
|
*new_block = true; |
|
|
|
*new_block = true; |
|
|
|
memcpy(lasthash, wb->prevhash, 65); |
|
|
|
memcpy(lasthash, wb->prevhash, 65); |
|
|
|
|
|
|
|
hex2bin(bin, lasthash, 32); |
|
|
|
|
|
|
|
swap_256(swap, bin); |
|
|
|
|
|
|
|
__bin2hex(lastswaphash, swap, 32); |
|
|
|
blockchange_id = wb->id; |
|
|
|
blockchange_id = wb->id; |
|
|
|
} |
|
|
|
} |
|
|
|
if (*new_block && ckp->logshares) { |
|
|
|
if (*new_block && ckp->logshares) { |
|
|
@ -1193,7 +1197,7 @@ out: |
|
|
|
static void *blockupdate(void *arg) |
|
|
|
static void *blockupdate(void *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ckpool_t *ckp = (ckpool_t *)arg; |
|
|
|
ckpool_t *ckp = (ckpool_t *)arg; |
|
|
|
char *buf = NULL, hash[68]; |
|
|
|
char *buf = NULL; |
|
|
|
char request[8]; |
|
|
|
char request[8]; |
|
|
|
|
|
|
|
|
|
|
|
pthread_detach(pthread_self()); |
|
|
|
pthread_detach(pthread_self()); |
|
|
@ -1204,14 +1208,12 @@ static void *blockupdate(void *arg) |
|
|
|
else |
|
|
|
else |
|
|
|
sprintf(request, "getlast"); |
|
|
|
sprintf(request, "getlast"); |
|
|
|
|
|
|
|
|
|
|
|
memset(hash, 0, 68); |
|
|
|
|
|
|
|
while (42) { |
|
|
|
while (42) { |
|
|
|
dealloc(buf); |
|
|
|
dealloc(buf); |
|
|
|
buf = send_recv_generator(ckp, request, GEN_LAX); |
|
|
|
buf = send_recv_generator(ckp, request, GEN_LAX); |
|
|
|
if (buf && strcmp(buf, hash) && !cmdmatch(buf, "failed")) { |
|
|
|
if (buf && strcmp(buf, lastswaphash) && !cmdmatch(buf, "failed")) { |
|
|
|
strcpy(hash, buf); |
|
|
|
LOGNOTICE("Block hash changed to %s", buf); |
|
|
|
LOGNOTICE("Block hash changed to %s", hash); |
|
|
|
update_base(ckp, GEN_PRIORITY); |
|
|
|
send_proc(ckp->stratifier, "update"); |
|
|
|
|
|
|
|
} else |
|
|
|
} else |
|
|
|
cksleep_ms(ckp->blockpoll); |
|
|
|
cksleep_ms(ckp->blockpoll); |
|
|
|
} |
|
|
|
} |
|
|
|