Remove unnecessary header length calculation for stratum header binary and only binary convert the correct length of the header.
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 49 50 51 52 53 54 55 56 57 58 59 60
diff --git a/miner.h b/miner.h
index de6fdb3..6e1c96a 100644
--- a/miner.h
+++ b/miner.h
@@ -1128,7 +1128,6 @@ struct stratum_work {
unsigned char **merkle_bin;
bool clean;
- size_t header_len;
double diff;
};
diff --git a/util.c b/util.c
index cb4c8dd..8b12fdc 100644
--- a/util.c
+++ b/util.c
@@ -1600,7 +1600,7 @@ static char *blank_merkle = "000000000000000000000000000000000000000000000000000
static bool parse_notify(struct pool *pool, json_t *val)
{
char *job_id, *prev_hash, *coinbase1, *coinbase2, *bbversion, *nbit,
- *ntime, *header;
+ *ntime, header[228];
unsigned char *cb1 = NULL, *cb2 = NULL;
size_t cb1_len, cb2_len, alloc_len;
bool clean, ret = false;
@@ -1682,19 +1682,17 @@ static bool parse_notify(struct pool *pool, json_t *val)
pool->merkles = merkles;
if (clean)
pool->nonce2 = 0;
- pool->merkle_offset = strlen(pool->bbversion) +
- strlen(pool->prev_hash);
- pool->swork.header_len = pool->merkle_offset +
+ pool->merkle_offset = 36;
+#if 0
+ header_len = strlen(pool->bbversion) +
+ strlen(pool->prev_hash);
/* merkle_hash */ 32 +
strlen(pool->ntime) +
strlen(pool->nbit) +
/* nonce */ 8 +
/* workpadding */ 96;
- pool->merkle_offset /= 2;
- pool->swork.header_len = pool->swork.header_len * 2 + 1;
- align_len(&pool->swork.header_len);
- header = alloca(pool->swork.header_len);
- snprintf(header, pool->swork.header_len,
+#endif
+ snprintf(header, 225,
"%s%s%s%s%s%s%s",
pool->bbversion,
pool->prev_hash,
@@ -1703,7 +1701,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
pool->nbit,
"00000000", /* nonce */
workpadding);
- ret = hex2bin(pool->header_bin, header, 128);
+ ret = hex2bin(pool->header_bin, header, 112);
if (unlikely(!ret)) {
applog(LOG_ERR, "Failed to convert header to header_bin in parse_notify");
goto out_unlock;