Browse Source

use gostd for merkle in case of stratum

windows v0.3
orignal 7 years ago
parent
commit
12224ad8d8
  1. 21
      cpu-miner.c
  2. 10
      gost.c
  3. 2
      miner.h

21
cpu-miner.c

@ -654,11 +654,22 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work) @@ -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);
/* Generate merkle root */
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);
}
if (opt_algo == ALGO_GOSTD)
{
gostd(merkle_root, sctx->job.coinbase, sctx->job.coinbase_size);
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 */
for (i = 0; i < sctx->xnonce2_size && !++sctx->job.xnonce2[i]; i++);

10
gost.c

@ -1223,6 +1223,16 @@ void sph_gostd(void *cc, const void *data, size_t len) @@ -1223,6 +1223,16 @@ void sph_gostd(void *cc, const void *data, size_t len)
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,
uint32_t max_nonce, unsigned long *hashes_done)
{

2
miner.h

@ -134,6 +134,8 @@ void sha256_init(uint32_t *state); @@ -134,6 +134,8 @@ void sha256_init(uint32_t *state);
void sha256_transform(uint32_t *state, const uint32_t *block, int swap);
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__)
#define HAVE_SHA256_4WAY 1
int sha256_use_4way();

Loading…
Cancel
Save