Browse Source

Rename pool gbt_coinbase variable to coinbase to combine it with the stratum coinbase data.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
8c8ef6ff9b
  1. 22
      cgminer.c
  2. 4
      miner.h

22
cgminer.c

@ -1625,7 +1625,7 @@ static unsigned char *__gbt_merkleroot(struct pool *pool)
if (unlikely(!merkle_hash)) if (unlikely(!merkle_hash))
quit(1, "Failed to calloc merkle_hash in __gbt_merkleroot"); quit(1, "Failed to calloc merkle_hash in __gbt_merkleroot");
gen_hash(pool->gbt_coinbase, merkle_hash, pool->coinbase_len); gen_hash(pool->coinbase, merkle_hash, pool->coinbase_len);
if (pool->gbt_txns) if (pool->gbt_txns)
memcpy(merkle_hash + 32, pool->txn_hashes, pool->gbt_txns * 32); memcpy(merkle_hash + 32, pool->txn_hashes, pool->gbt_txns * 32);
@ -1698,7 +1698,7 @@ static void gen_gbt_work(struct pool *pool, struct work *work)
update_gbt(pool); update_gbt(pool);
cg_wlock(&pool->gbt_lock); cg_wlock(&pool->gbt_lock);
memcpy(pool->gbt_coinbase + pool->nonce2_offset, &pool->nonce2, 4); memcpy(pool->coinbase + pool->nonce2_offset, &pool->nonce2, 4);
pool->nonce2++; pool->nonce2++;
cg_dwlock(&pool->gbt_lock); cg_dwlock(&pool->gbt_lock);
merkleroot = __gbt_merkleroot(pool); merkleroot = __gbt_merkleroot(pool);
@ -1710,7 +1710,7 @@ static void gen_gbt_work(struct pool *pool, struct work *work)
memcpy(work->target, pool->gbt_target, 32); memcpy(work->target, pool->gbt_target, 32);
work->gbt_coinbase = bin2hex(pool->gbt_coinbase, pool->coinbase_len); work->gbt_coinbase = bin2hex(pool->coinbase, pool->coinbase_len);
/* For encoding the block data on submission */ /* For encoding the block data on submission */
work->gbt_txns = pool->gbt_txns + 1; work->gbt_txns = pool->gbt_txns + 1;
@ -1799,16 +1799,16 @@ static bool gbt_decode(struct pool *pool, json_t *res_val)
/* We add 4 bytes of extra data corresponding to nonce2 of stratum */ /* We add 4 bytes of extra data corresponding to nonce2 of stratum */
cal_len = pool->coinbase_len + 1; cal_len = pool->coinbase_len + 1;
align_len(&cal_len); align_len(&cal_len);
free(pool->gbt_coinbase); free(pool->coinbase);
pool->gbt_coinbase = calloc(cal_len, 1); pool->coinbase = calloc(cal_len, 1);
if (unlikely(!pool->gbt_coinbase)) if (unlikely(!pool->coinbase))
quit(1, "Failed to calloc pool gbt_coinbase in gbt_decode"); quit(1, "Failed to calloc pool coinbase in gbt_decode");
hex2bin(pool->gbt_coinbase, pool->coinbasetxn, 42); hex2bin(pool->coinbase, pool->coinbasetxn, 42);
extra_len = (uint8_t *)(pool->gbt_coinbase + 41); extra_len = (uint8_t *)(pool->coinbase + 41);
orig_len = *extra_len; orig_len = *extra_len;
hex2bin(pool->gbt_coinbase + 42, pool->coinbasetxn + 84, orig_len); hex2bin(pool->coinbase + 42, pool->coinbasetxn + 84, orig_len);
*extra_len += 4; *extra_len += 4;
hex2bin(pool->gbt_coinbase + 42 + *extra_len, pool->coinbasetxn + 84 + (orig_len * 2), hex2bin(pool->coinbase + 42 + *extra_len, pool->coinbasetxn + 84 + (orig_len * 2),
cbt_len - orig_len - 42); cbt_len - orig_len - 42);
pool->nonce2_offset = orig_len + 42; pool->nonce2_offset = orig_len + 42;

4
miner.h

@ -1182,7 +1182,6 @@ struct pool {
char *sockbuf; char *sockbuf;
size_t sockbuf_size; size_t sockbuf_size;
char *sockaddr_url; /* stripped url used for sockaddr */ char *sockaddr_url; /* stripped url used for sockaddr */
char *stratum_coinbase;
char *nonce1; char *nonce1;
unsigned char *nonce1bin; unsigned char *nonce1bin;
size_t n1_len; size_t n1_len;
@ -1212,13 +1211,14 @@ struct pool {
uint32_t gbt_version; uint32_t gbt_version;
uint32_t curtime; uint32_t curtime;
uint32_t gbt_bits; uint32_t gbt_bits;
unsigned char *gbt_coinbase;
unsigned char *txn_hashes; unsigned char *txn_hashes;
int gbt_txns; int gbt_txns;
int coinbase_len; int coinbase_len;
/* Shared by both stratum & GBT */ /* Shared by both stratum & GBT */
unsigned char *coinbase;
int nonce2_offset; int nonce2_offset;
struct timeval tv_lastwork; struct timeval tv_lastwork;
}; };

Loading…
Cancel
Save