Share coinbase_len variable b/w stratum and gbt and setup more gbt solo parameters.
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/cgminer.c b/cgminer.c
index 94297bf..351476c 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2315,6 +2315,10 @@ static bool gbt_solo_decode(struct pool *pool, json_t *res_val)
pool->coinbase[41 + ofs + 4] = 1;
u64 = (uint64_t *)&(pool->coinbase[41 + ofs + 4 + 1]);
*u64 = htole64(coinbasevalue);
+
+ pool->nonce2 = 0;
+ pool->n2size = 4;
+ pool->coinbase_len = 41 + 50 + 4 + 1 + 8 + 25 + 4; // Fixed size
cg_wunlock(&pool->gbt_lock);
return true;
@@ -6374,7 +6378,7 @@ static bool setup_gbt_solo(CURL *curl, struct pool *pool)
memcpy(pool->coinbase + 41 + 50 + 4 + 1 + 8, pool->script_pubkey, 25);
if (opt_debug) {
- char *cb = bin2hex(pool->coinbase, 41 + 50 + 4 + 1 + 8 + 25 + 4);
+ char *cb = bin2hex(pool->coinbase, pool->coinbase_len);
applog(LOG_DEBUG, "Pool %d coinbase %s", pool->pool_no, cb);
free(cb);
@@ -6764,7 +6768,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
cg_dwlock(&pool->data_lock);
/* Generate merkle root */
- gen_hash(pool->coinbase, merkle_root, pool->swork.cb_len);
+ gen_hash(pool->coinbase, merkle_root, pool->coinbase_len);
memcpy(merkle_sha, merkle_root, 32);
for (i = 0; i < pool->swork.merkles; i++) {
memcpy(merkle_sha + 32, pool->swork.merkle_bin[i], 32);
diff --git a/miner.h b/miner.h
index 5e35de3..fb9c238 100644
--- a/miner.h
+++ b/miner.h
@@ -1132,7 +1132,6 @@ struct stratum_work {
char *ntime;
bool clean;
- size_t cb_len;
size_t header_len;
int merkles;
double diff;
@@ -1254,7 +1253,6 @@ struct pool {
uint32_t gbt_bits;
unsigned char *txn_hashes;
int gbt_txns;
- int coinbase_len;
bool gbt_solo;
int merkles;
@@ -1267,6 +1265,7 @@ struct pool {
/* Shared by both stratum & GBT */
unsigned char *coinbase;
+ int coinbase_len;
int nonce2_offset;
unsigned char header_bin[128];
int merkle_offset;
diff --git a/util.c b/util.c
index 4549a7c..1e36123 100644
--- a/util.c
+++ b/util.c
@@ -1655,7 +1655,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
pool->swork.nbit = nbit;
pool->swork.ntime = ntime;
pool->swork.clean = clean;
- alloc_len = pool->swork.cb_len = cb1_len + pool->n1_len + pool->n2size + cb2_len;
+ alloc_len = pool->coinbase_len = cb1_len + pool->n1_len + pool->n2size + cb2_len;
pool->nonce2_offset = cb1_len + pool->n1_len;
for (i = 0; i < pool->swork.merkles; i++)
@@ -1729,8 +1729,12 @@ static bool parse_notify(struct pool *pool, json_t *val)
memcpy(pool->coinbase, cb1, cb1_len);
memcpy(pool->coinbase + cb1_len, pool->nonce1bin, pool->n1_len);
memcpy(pool->coinbase + cb1_len + pool->n1_len + pool->n2size, cb2, cb2_len);
- char *shit = bin2hex(pool->coinbase, cb1_len + pool->n1_len + pool->n2size + cb2_len);
- applog(LOG_ERR, "SHIT is %s", shit);
+ if (opt_debug) {
+ char *cb = bin2hex(pool->coinbase, pool->coinbase_len);
+
+ applog(LOG_DEBUG, "Pool %d coinbase %s", pool->pool_no, cb);
+ free(cb);
+ }
out_unlock:
cg_wunlock(&pool->data_lock);
@@ -1753,7 +1757,6 @@ out_unlock:
if (pool == current_pool())
opt_work_update = true;
out:
- exit(0);
return ret;
}