mirror of
https://github.com/GOSTSec/sgminer
synced 2025-03-10 12:41:02 +00:00
Perform merkle bin hex2bin on stratum notify to avoid doing it on each work generation.
This commit is contained in:
parent
8bc469e916
commit
5237bf350d
@ -5605,10 +5605,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
|
||||
gen_hash(pool->coinbase, merkle_root, pool->swork.cb_len);
|
||||
memcpy(merkle_sha, merkle_root, 32);
|
||||
for (i = 0; i < pool->swork.merkles; i++) {
|
||||
unsigned char merkle_bin[32];
|
||||
|
||||
hex2bin(merkle_bin, pool->swork.merkle[i], 32);
|
||||
memcpy(merkle_sha + 32, merkle_bin, 32);
|
||||
memcpy(merkle_sha + 32, pool->swork.merkle_bin[i], 32);
|
||||
gen_hash(merkle_sha, merkle_root, 64);
|
||||
memcpy(merkle_sha, merkle_root, 32);
|
||||
}
|
||||
|
2
miner.h
2
miner.h
@ -1088,7 +1088,7 @@ enum pool_enable {
|
||||
struct stratum_work {
|
||||
char *job_id;
|
||||
char *prev_hash;
|
||||
char **merkle;
|
||||
unsigned char **merkle_bin;
|
||||
char *bbversion;
|
||||
char *nbit;
|
||||
char *ntime;
|
||||
|
18
util.c
18
util.c
@ -1258,11 +1258,19 @@ static bool parse_notify(struct pool *pool, json_t *val)
|
||||
pool->nonce2_offset = cb1_len + pool->n1_len;
|
||||
|
||||
for (i = 0; i < pool->swork.merkles; i++)
|
||||
free(pool->swork.merkle[i]);
|
||||
free(pool->swork.merkle_bin[i]);
|
||||
if (merkles) {
|
||||
pool->swork.merkle = realloc(pool->swork.merkle, sizeof(char *) * merkles + 1);
|
||||
for (i = 0; i < merkles; i++)
|
||||
pool->swork.merkle[i] = json_array_string(arr, i);
|
||||
pool->swork.merkle_bin = realloc(pool->swork.merkle_bin,
|
||||
sizeof(char *) * merkles + 1);
|
||||
for (i = 0; i < merkles; i++) {
|
||||
char *merkle = json_array_string(arr, i);
|
||||
|
||||
pool->swork.merkle_bin[i] = malloc(32);
|
||||
if (unlikely(!pool->swork.merkle_bin[i]))
|
||||
quit(1, "Failed to malloc pool swork merkle_bin");
|
||||
hex2bin(pool->swork.merkle_bin[i], merkle, 32);
|
||||
free(merkle);
|
||||
}
|
||||
}
|
||||
pool->swork.merkles = merkles;
|
||||
if (clean)
|
||||
@ -1300,8 +1308,6 @@ static bool parse_notify(struct pool *pool, json_t *val)
|
||||
applog(LOG_DEBUG, "prev_hash: %s", prev_hash);
|
||||
applog(LOG_DEBUG, "coinbase1: %s", coinbase1);
|
||||
applog(LOG_DEBUG, "coinbase2: %s", coinbase2);
|
||||
for (i = 0; i < merkles; i++)
|
||||
applog(LOG_DEBUG, "merkle%d: %s", i, pool->swork.merkle[i]);
|
||||
applog(LOG_DEBUG, "bbversion: %s", bbversion);
|
||||
applog(LOG_DEBUG, "nbit: %s", nbit);
|
||||
applog(LOG_DEBUG, "ntime: %s", ntime);
|
||||
|
Loading…
x
Reference in New Issue
Block a user