Browse Source

decred: remove some useless double flip

master
Tanguy Pruvot 9 years ago
parent
commit
d58490911a
  1. 2
      Algo256/decred.cu
  2. 2
      Algo256/vanilla.cu
  3. 35
      ccminer.cpp

2
Algo256/decred.cu

@ -36,7 +36,7 @@ extern "C" void decred_hash(void *output, const void *input)
__constant__ uint32_t _ALIGN(4) d_data[24]; __constant__ uint32_t _ALIGN(4) d_data[24];
/* 8 adapters max */ /* 16 adapters max */
static uint32_t *d_resNonce[MAX_GPUS]; static uint32_t *d_resNonce[MAX_GPUS];
static uint32_t *h_resNonce[MAX_GPUS]; static uint32_t *h_resNonce[MAX_GPUS];

2
Algo256/vanilla.cu

@ -32,7 +32,7 @@ extern "C" {
__constant__ uint32_t d_data[16]; __constant__ uint32_t d_data[16];
/* 8 adapters max */ /* 16 gpu threads max */
static uint32_t *d_resNonce[MAX_GPUS]; static uint32_t *d_resNonce[MAX_GPUS];
static uint32_t *h_resNonce[MAX_GPUS]; static uint32_t *h_resNonce[MAX_GPUS];

35
ccminer.cpp

@ -1324,9 +1324,8 @@ err_out:
static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
{ {
uint32_t extraheader[32] = { 0 };
uchar merkle_root[64] = { 0 }; uchar merkle_root[64] = { 0 };
int i, headersize = 0; int i;
if (!sctx->job.job_id) { if (!sctx->job.job_id) {
// applog(LOG_WARNING, "stratum_gen_work: job not yet retrieved"); // applog(LOG_WARNING, "stratum_gen_work: job not yet retrieved");
@ -1349,10 +1348,7 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
/* Generate merkle root */ /* Generate merkle root */
switch (opt_algo) { switch (opt_algo) {
case ALGO_DECRED: case ALGO_DECRED:
// getwork over stratum, getwork merkle + header passed in coinb1 // getwork over stratum, no merkle to generate
memcpy(merkle_root, sctx->job.coinbase, 32);
headersize = min((int)sctx->job.coinbase_size - 32, sizeof(extraheader));
memcpy(extraheader, &sctx->job.coinbase[32], headersize);
break; break;
case ALGO_HEAVY: case ALGO_HEAVY:
case ALGO_MJOLLNIR: case ALGO_MJOLLNIR:
@ -1374,7 +1370,7 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
memcpy(merkle_root + 32, sctx->job.merkle[i], 32); memcpy(merkle_root + 32, sctx->job.merkle[i], 32);
if (opt_algo == ALGO_HEAVY || opt_algo == ALGO_MJOLLNIR) if (opt_algo == ALGO_HEAVY || opt_algo == ALGO_MJOLLNIR)
heavycoin_hash(merkle_root, merkle_root, 64); heavycoin_hash(merkle_root, merkle_root, 64);
else if (!headersize) else
sha256d(merkle_root, merkle_root, 64); sha256d(merkle_root, merkle_root, 64);
} }
@ -1386,26 +1382,25 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
work->data[0] = le32dec(sctx->job.version); work->data[0] = le32dec(sctx->job.version);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
work->data[1 + i] = le32dec((uint32_t *)sctx->job.prevhash + i); work->data[1 + i] = le32dec((uint32_t *)sctx->job.prevhash + i);
for (i = 0; i < 8; i++)
work->data[9 + i] = be32dec((uint32_t *)merkle_root + i);
if (opt_algo == ALGO_DECRED) { if (opt_algo == ALGO_DECRED) {
for (i = 0; i < 8; i++) // prevhash for (i = 0; i < 8; i++) // reversed prevhash
work->data[1 + i] = swab32(work->data[1 + i]); work->data[1 + i] = swab32(work->data[1 + i]);
for (i = 0; i < 8; i++) // merkle // decred header (coinb1) [merkle...nonce]
work->data[9 + i] = swab32(work->data[9 + i]); memcpy(&work->data[9], sctx->job.coinbase, 112);
for (i = 0; i < headersize/4; i++) // header
work->data[17 + i] = extraheader[i];
// extradata // extradata
uint32_t* extradata = (uint32_t*) sctx->xnonce1; if (sctx->xnonce1_size > sizeof(work->data)-(36*4)) {
for (i = 0; i < sctx->xnonce1_size/4; i++) // should never happen...
work->data[36 + i] = extradata[i]; applog(LOG_ERR, "extranonce size overflow!");
for (i = 36 + sctx->xnonce1_size/4; i < 45; i++) sctx->xnonce1_size = sizeof(work->data)-(36*4);
work->data[i] = 0; }
work->data[37] = (rand()*4) << 8; memcpy(&work->data[36], sctx->xnonce1, sctx->xnonce1_size);
work->data[37] = (rand()*4) << 8; // random work data
sctx->job.height = work->data[32]; sctx->job.height = work->data[32];
//applog_hex(work->data, 180); //applog_hex(work->data, 180);
} else { } else {
for (i = 0; i < 8; i++)
work->data[9 + i] = be32dec((uint32_t *)merkle_root + i);
work->data[17] = le32dec(sctx->job.ntime); work->data[17] = le32dec(sctx->job.ntime);
work->data[18] = le32dec(sctx->job.nbits); work->data[18] = le32dec(sctx->job.nbits);
work->data[20] = 0x80000000; work->data[20] = 0x80000000;

Loading…
Cancel
Save