mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Cache the binary generation of coinbase1 and 2 on stratum, avoiding a hex2bin of coinbase1 and 2 on each work generation.
This commit is contained in:
parent
b1f57595bd
commit
fef649dfef
@ -5611,10 +5611,10 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
|
|||||||
coinbase = calloc(alloc_len, 1);
|
coinbase = calloc(alloc_len, 1);
|
||||||
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");
|
||||||
hex2bin(coinbase, pool->swork.coinbase1, pool->swork.cb1_len);
|
memcpy(coinbase, pool->swork.cb1, pool->swork.cb1_len);
|
||||||
hex2bin(coinbase + pool->swork.cb1_len, pool->nonce1, pool->n1_len);
|
hex2bin(coinbase + pool->swork.cb1_len, pool->nonce1, 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);
|
||||||
hex2bin(coinbase + pool->swork.cb1_len + pool->n1_len + pool->n2size, pool->swork.coinbase2, pool->swork.cb2_len);
|
memcpy(coinbase + pool->swork.cb1_len + pool->n1_len + pool->n2size, pool->swork.cb2, pool->swork.cb2_len);
|
||||||
|
|
||||||
/* Generate merkle root */
|
/* Generate merkle root */
|
||||||
gen_hash(coinbase, merkle_root, pool->swork.cb_len);
|
gen_hash(coinbase, merkle_root, pool->swork.cb_len);
|
||||||
|
2
miner.h
2
miner.h
@ -1066,6 +1066,8 @@ struct stratum_work {
|
|||||||
char *nbit;
|
char *nbit;
|
||||||
char *ntime;
|
char *ntime;
|
||||||
bool clean;
|
bool clean;
|
||||||
|
unsigned char *cb1;
|
||||||
|
unsigned char *cb2;
|
||||||
|
|
||||||
size_t cb1_len;
|
size_t cb1_len;
|
||||||
size_t cb2_len;
|
size_t cb2_len;
|
||||||
|
11
util.c
11
util.c
@ -1277,6 +1277,17 @@ static bool parse_notify(struct pool *pool, json_t *val)
|
|||||||
/* workpadding */ 96;
|
/* workpadding */ 96;
|
||||||
pool->swork.header_len = pool->swork.header_len * 2 + 1;
|
pool->swork.header_len = pool->swork.header_len * 2 + 1;
|
||||||
align_len(&pool->swork.header_len);
|
align_len(&pool->swork.header_len);
|
||||||
|
|
||||||
|
free(pool->swork.cb1);
|
||||||
|
free(pool->swork.cb2);
|
||||||
|
pool->swork.cb1 = calloc(pool->swork.cb1_len, 1);
|
||||||
|
if (unlikely(!pool->swork.cb1))
|
||||||
|
quit(1, "Failed to calloc swork cb1 in parse_notify");
|
||||||
|
hex2bin(pool->swork.cb1, pool->swork.coinbase1, pool->swork.cb1_len);
|
||||||
|
pool->swork.cb2 = calloc(pool->swork.cb2_len, 1);
|
||||||
|
if (unlikely(!pool->swork.cb2))
|
||||||
|
quit(1, "Failed to calloc swork cb2 in parse_notify");
|
||||||
|
hex2bin(pool->swork.cb2, pool->swork.coinbase2, pool->swork.cb2_len);
|
||||||
cg_wunlock(&pool->data_lock);
|
cg_wunlock(&pool->data_lock);
|
||||||
|
|
||||||
if (opt_protocol) {
|
if (opt_protocol) {
|
||||||
|
Loading…
Reference in New Issue
Block a user