mirror of
https://github.com/GOSTSec/cpuminer-gostd
synced 2025-01-14 08:47:53 +00:00
use gostd for merkle in case of stratum
This commit is contained in:
parent
28a1544650
commit
12224ad8d8
21
cpu-miner.c
21
cpu-miner.c
@ -654,11 +654,22 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
|
|||||||
memcpy(work->xnonce2, sctx->job.xnonce2, sctx->xnonce2_size);
|
memcpy(work->xnonce2, sctx->job.xnonce2, sctx->xnonce2_size);
|
||||||
|
|
||||||
/* Generate merkle root */
|
/* Generate merkle root */
|
||||||
sha256d(merkle_root, sctx->job.coinbase, sctx->job.coinbase_size);
|
if (opt_algo == ALGO_GOSTD)
|
||||||
for (i = 0; i < sctx->job.merkle_count; i++) {
|
{
|
||||||
memcpy(merkle_root + 32, sctx->job.merkle[i], 32);
|
gostd(merkle_root, sctx->job.coinbase, sctx->job.coinbase_size);
|
||||||
sha256d(merkle_root, merkle_root, 64);
|
for (i = 0; i < sctx->job.merkle_count; i++) {
|
||||||
}
|
memcpy(merkle_root + 32, merkle_root, 32);
|
||||||
|
gostd(merkle_root, merkle_root, 64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sha256d(merkle_root, sctx->job.coinbase, sctx->job.coinbase_size);
|
||||||
|
for (i = 0; i < sctx->job.merkle_count; i++) {
|
||||||
|
memcpy(merkle_root + 32, sctx->job.merkle[i], 32);
|
||||||
|
sha256d(merkle_root, merkle_root, 64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Increment extranonce2 */
|
/* Increment extranonce2 */
|
||||||
for (i = 0; i < sctx->xnonce2_size && !++sctx->job.xnonce2[i]; i++);
|
for (i = 0; i < sctx->xnonce2_size && !++sctx->job.xnonce2[i]; i++);
|
||||||
|
10
gost.c
10
gost.c
@ -1223,6 +1223,16 @@ void sph_gostd(void *cc, const void *data, size_t len)
|
|||||||
hash_256(digest, 64, cc);
|
hash_256(digest, 64, cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gostd(void *output, const void *input, size_t len)
|
||||||
|
{
|
||||||
|
unsigned char hash[64];
|
||||||
|
|
||||||
|
sph_gost512(hash, (const void*)input, len);
|
||||||
|
sph_gost256(hash, (const void*)hash, 64);
|
||||||
|
|
||||||
|
memcpy(output, hash, 32);
|
||||||
|
}
|
||||||
|
|
||||||
int scanhash_gostd(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
|
int scanhash_gostd(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
|
||||||
uint32_t max_nonce, unsigned long *hashes_done)
|
uint32_t max_nonce, unsigned long *hashes_done)
|
||||||
{
|
{
|
||||||
|
2
miner.h
2
miner.h
@ -134,6 +134,8 @@ void sha256_init(uint32_t *state);
|
|||||||
void sha256_transform(uint32_t *state, const uint32_t *block, int swap);
|
void sha256_transform(uint32_t *state, const uint32_t *block, int swap);
|
||||||
void sha256d(unsigned char *hash, const unsigned char *data, int len);
|
void sha256d(unsigned char *hash, const unsigned char *data, int len);
|
||||||
|
|
||||||
|
void gostd(void *output, const void *input, size_t len);
|
||||||
|
|
||||||
#if defined(__ARM_NEON__) || defined(__i386__) || defined(__x86_64__)
|
#if defined(__ARM_NEON__) || defined(__i386__) || defined(__x86_64__)
|
||||||
#define HAVE_SHA256_4WAY 1
|
#define HAVE_SHA256_4WAY 1
|
||||||
int sha256_use_4way();
|
int sha256_use_4way();
|
||||||
|
Loading…
Reference in New Issue
Block a user