Browse Source

Check inconclusive block submits against their height hash to see if they were already submitted via other means.

master
Con Kolivas 8 years ago
parent
commit
9d8c45930b
  1. 14
      src/generator.c
  2. 1
      src/generator.h
  3. 21
      src/stratifier.c

14
src/generator.c

@ -330,6 +330,20 @@ bool generator_submitblock(ckpool_t *ckp, char *buf)
return submit_block(cs, buf + 64 + 1);
}
bool generator_get_blockhash(ckpool_t *ckp, int height, char *hash)
{
gdata_t *gdata = ckp->gdata;
server_instance_t *si;
connsock_t *cs;
if (unlikely(!(si = gdata->current_si))) {
LOGWARNING("No live current server in generator_get_blockhash");
return false;
}
cs = &si->cs;
return get_blockhash(cs, height, hash);
}
static void gen_loop(proc_instance_t *pi)
{
server_instance_t *si = NULL, *old_si;

1
src/generator.h

@ -22,6 +22,7 @@ int generator_getbest(ckpool_t *ckp, char *hash);
bool generator_checkaddr(ckpool_t *ckp, const char *addr);
char *generator_get_txn(ckpool_t *ckp, const char *hash);
bool generator_submitblock(ckpool_t *ckp, char *buf);
bool generator_get_blockhash(ckpool_t *ckp, int height, char *hash);
void *generator(void *arg);
#endif /* GENERATOR_H */

21
src/stratifier.c

@ -2047,7 +2047,7 @@ static void send_node_block(sdata_t *sdata, const char *enonce1, const char *non
* workbase readcount */
static bool
process_block(ckpool_t *ckp, const workbase_t *wb, const char *coinbase, const int cblen,
const uchar *data, const uchar *hash, uchar *swap32, char *blockhash)
const uchar *data, const uchar *hash, uchar *flip32, char *blockhash)
{
char *gbt_block, varint[12];
int txns = wb->txns + 1;
@ -2055,8 +2055,8 @@ process_block(ckpool_t *ckp, const workbase_t *wb, const char *coinbase, const i
bool ret;
gbt_block = ckalloc(1024);
flip_32(swap32, hash);
__bin2hex(blockhash, swap32, 32);
flip_32(flip32, hash);
__bin2hex(blockhash, flip32, 32);
/* Message format: "hash,data" */
sprintf(gbt_block, "%s,", blockhash);
@ -2084,6 +2084,21 @@ process_block(ckpool_t *ckp, const workbase_t *wb, const char *coinbase, const i
ret = generator_submitblock(ckp, gbt_block);
free(gbt_block);
/* Check failures that may be inconclusive but were submitted via other
* means. */
if (!ret) {
char heighthash[68] = {}, rhash[68] = {};
uchar swap256[32];
swap_256(swap256, flip32);
__bin2hex(rhash, swap256, 32);
if (generator_get_blockhash(ckp, wb->height, heighthash)) {
ret = !strncmp(rhash, heighthash, 64);
LOGWARNING("Hash for block height %d confirms block was %s",
wb->height, ret ? "ACCEPTED" : "REJECTED");
}
}
return ret;
}

Loading…
Cancel
Save