Browse Source

correct kernels and merkle tree calculation

pull/1/head
orignal 7 years ago
parent
commit
23724ef9ff
  1. 11
      algorithm.c
  2. 2
      kernel/gostcoin-mod.cl
  3. 6
      sgminer.c

11
algorithm.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "algorithm.h"
#include "sph/sph_sha2.h"
#include "sph/sph_gost.h"
#include "ocl.h"
#include "ocl/build_kernel.h"
@ -106,6 +107,13 @@ void gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash) @@ -106,6 +107,13 @@ void gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash)
sph_sha256_close(&ctx_sha2, hash);
}
void gostcoin_gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash)
{
unsigned char h1[64];
sph_gost512(h1, (const void*)data, len);
sph_gost256(hash, (const void*)h1, 64);
}
void sha256d_midstate(struct work *work)
{
unsigned char data[64];
@ -1249,7 +1257,8 @@ static algorithm_settings_t algos[] = { @@ -1249,7 +1257,8 @@ static algorithm_settings_t algos[] = {
{ "pascal", ALGO_PASCAL, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 0, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, pascal_regenhash, pascal_midstate, NULL, queue_pascal_kernel, NULL, NULL },
{ "gostcoin-mod", ALGO_GOSTCOIN, "", 1, 256, 256, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 2, 4 * 8 * 4194304, 0, gostcoin_regenhash, NULL, NULL, queue_gostcoin_mod_kernel, NULL, NULL },
{ "gostcoin-mod", ALGO_GOSTCOIN, "", 1, 1, 1, 0, 0, 0xFF, 0xFFFFULL, 0x0000ffffUL, 0, 4 * 8 * 4194304, 0, gostcoin_regenhash, NULL, NULL, queue_gostcoin_mod_kernel, gostcoin_gen_hash, NULL },
// Terminator (do not remove)
{ NULL, ALGO_UNK, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }

2
kernel/gostcoin-mod.cl

@ -930,6 +930,6 @@ __kernel void search(__global unsigned char* block, volatile __global uint* outp @@ -930,6 +930,6 @@ __kernel void search(__global unsigned char* block, volatile __global uint* outp
GOST_g_0(hash, hash1);
// result is first 32 bytes of hash
if (SWAP8 (hash[0]) <= target)
output[output[0xFF]++] = nonce;
output[output[0xFF]++] = SWAP4 (nonce);
}

6
sgminer.c

@ -6150,7 +6150,11 @@ static void gen_stratum_work(struct pool *pool, struct work *work) @@ -6150,7 +6150,11 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
/* Generate merkle root */
pool->algorithm.gen_hash(pool->coinbase, pool->swork.cb_len, merkle_root);
memcpy(merkle_sha, merkle_root, 32);
for (i = 0; i < pool->swork.merkles; i++) {
for (i = 0; i < pool->swork.merkles; i++)
{
if (pool->algorithm.type != ALGO_GOSTCOIN) // TODO: remove after hard fork 1
memcpy(merkle_sha + 32, merkle_sha, 32);
else
memcpy(merkle_sha + 32, pool->swork.merkle_bin[i], 32);
gen_hash(merkle_sha, 64, merkle_root);
memcpy(merkle_sha, merkle_root, 32);

Loading…
Cancel
Save