Browse Source

use gostd for merkle in case of stratum

2upstream
orignal 7 years ago
parent
commit
23d5ea88c6
  1. 8
      ccminer.cpp
  2. 9
      gost/gost.cu
  3. 2
      miner.h

8
ccminer.cpp

@ -1500,6 +1500,9 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) @@ -1500,6 +1500,9 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
case ALGO_WHIRLCOIN:
SHA256((uchar*)sctx->job.coinbase, sctx->job.coinbase_size, (uchar*)merkle_root);
break;
case ALGO_GOSTD:
gostd(merkle_root, sctx->job.coinbase, (int)sctx->job.coinbase_size);
break;
case ALGO_WHIRLPOOL:
default:
sha256d(merkle_root, sctx->job.coinbase, (int)sctx->job.coinbase_size);
@ -1509,6 +1512,11 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) @@ -1509,6 +1512,11 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
memcpy(merkle_root + 32, sctx->job.merkle[i], 32);
if (opt_algo == ALGO_HEAVY || opt_algo == ALGO_MJOLLNIR)
heavycoin_hash(merkle_root, merkle_root, 64);
if (opt_algo == ALGO_GOSTD)
{
memcpy(merkle_root + 32, merkle_root, 32);
gostd(merkle_root, merkle_root, 64);
}
else
sha256d(merkle_root, merkle_root, 64);
}

9
gost/gost.cu

@ -21,6 +21,15 @@ extern "C" void gostd_hash(void *output, const void *input) @@ -21,6 +21,15 @@ extern "C" void gostd_hash(void *output, const void *input)
memcpy(output, hash, 32);
}
extern "C" void gostd(void *output, const void *input, size_t len)
{
unsigned char _ALIGN(64) hash[64];
sph_gost512(hash, (const void*)input, len);
sph_gost256(hash, (const void*)hash, 64);
memcpy(output, hash, 32);
}
//#define _DEBUG
#define _DEBUG_PREFIX "gost"

2
miner.h

@ -268,6 +268,8 @@ void sha256_init(uint32_t *state); @@ -268,6 +268,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);
#define HAVE_SHA256_4WAY 0
#define HAVE_SHA256_8WAY 0

Loading…
Cancel
Save