Generate a header bin from gbt solo as per the cached stratum one.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/cgminer.c b/cgminer.c
index 3336df8..10a3738 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2214,6 +2214,7 @@ static bool gbt_solo_decode(struct pool *pool, json_t *res_val)
uint64_t coinbasevalue;
const char *flags;
const char *bits;
+ char header[228];
int ofs = 0, len;
uint64_t *u64;
uint32_t *u32;
@@ -2325,6 +2326,17 @@ static bool gbt_solo_decode(struct pool *pool, json_t *res_val)
pool->coinbase_len = 41 + 50 + 4 + 1 + 8 + 25 + 4; // Fixed size
cg_wunlock(&pool->gbt_lock);
+ snprintf(header, 225, "%s%s%s%s%s%s%s",
+ pool->bbversion,
+ pool->prev_hash,
+ "0000000000000000000000000000000000000000000000000000000000000000",
+ pool->ntime,
+ pool->nbit,
+ "00000000", /* nonce */
+ workpadding);
+ if (unlikely(!hex2bin(pool->header_bin, header, 112)))
+ quit(1, "Failed to hex2bin header in gbt_solo_decode");
+
return true;
}
@@ -6784,7 +6796,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
flip32(swap32, data32);
/* Copy the data template from header_bin */
- memcpy(work->data, pool->header_bin, 128);
+ memcpy(work->data, pool->header_bin, 112);
memcpy(work->data + pool->merkle_offset, merkle_root, 32);
/* Store the stratum work diff to check it still matches the pool's
@@ -6800,7 +6812,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
if (opt_debug) {
char *header, *merkle_hash;
- header = bin2hex(work->data, 128);
+ header = bin2hex(work->data, 112);
merkle_hash = bin2hex((const unsigned char *)merkle_root, 32);
applog(LOG_DEBUG, "Generated stratum merkle %s", merkle_hash);
applog(LOG_DEBUG, "Generated stratum header %s", header);