Browse Source

Cache the hex2bin of pool nonce1 in stratum, avoiding hex2bin on each work generation.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
b423fe9de8
  1. 2
      cgminer.c
  2. 1
      miner.h
  3. 5
      util.c

2
cgminer.c

@ -5612,7 +5612,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
if (unlikely(!coinbase)) if (unlikely(!coinbase))
quit(1, "Failed to calloc coinbase in gen_stratum_work"); quit(1, "Failed to calloc coinbase in gen_stratum_work");
memcpy(coinbase, pool->swork.cb1, pool->swork.cb1_len); memcpy(coinbase, pool->swork.cb1, pool->swork.cb1_len);
hex2bin(coinbase + pool->swork.cb1_len, pool->nonce1, pool->n1_len); memcpy(coinbase + pool->swork.cb1_len, pool->nonce1bin, pool->n1_len);
hex2bin(coinbase + pool->swork.cb1_len + pool->n1_len, work->nonce2, pool->n2size); hex2bin(coinbase + pool->swork.cb1_len + pool->n1_len, work->nonce2, pool->n2size);
memcpy(coinbase + pool->swork.cb1_len + pool->n1_len + pool->n2size, pool->swork.cb2, pool->swork.cb2_len); memcpy(coinbase + pool->swork.cb1_len + pool->n1_len + pool->n2size, pool->swork.cb2, pool->swork.cb2_len);

1
miner.h

@ -1154,6 +1154,7 @@ struct pool {
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 *nonce1; char *nonce1;
unsigned char *nonce1bin;
size_t n1_len; size_t n1_len;
uint32_t nonce2; uint32_t nonce2;
int n2size; int n2size;

5
util.c

@ -1718,6 +1718,11 @@ resend:
pool->sessionid = sessionid; pool->sessionid = sessionid;
pool->nonce1 = nonce1; pool->nonce1 = nonce1;
pool->n1_len = strlen(nonce1) / 2; pool->n1_len = strlen(nonce1) / 2;
free(pool->nonce1bin);
pool->nonce1bin = calloc(pool->n1_len, 1);
if (unlikely(!pool->nonce1bin))
quit(1, "Failed to calloc pool->nonce1bin in initiate_stratum");
hex2bin(pool->nonce1bin, pool->nonce1, pool->n1_len);
pool->n2size = n2size; pool->n2size = n2size;
cg_wunlock(&pool->data_lock); cg_wunlock(&pool->data_lock);

Loading…
Cancel
Save