mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-08 22:07:56 +00:00
decred: remove some useless double flip
This commit is contained in:
parent
35738cec23
commit
d58490911a
@ -36,7 +36,7 @@ extern "C" void decred_hash(void *output, const void *input)
|
||||
|
||||
__constant__ uint32_t _ALIGN(4) d_data[24];
|
||||
|
||||
/* 8 adapters max */
|
||||
/* 16 adapters max */
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
|
||||
|
@ -32,7 +32,7 @@ extern "C" {
|
||||
|
||||
__constant__ uint32_t d_data[16];
|
||||
|
||||
/* 8 adapters max */
|
||||
/* 16 gpu threads max */
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
|
||||
|
35
ccminer.cpp
35
ccminer.cpp
@ -1324,9 +1324,8 @@ err_out:
|
||||
|
||||
static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
|
||||
{
|
||||
uint32_t extraheader[32] = { 0 };
|
||||
uchar merkle_root[64] = { 0 };
|
||||
int i, headersize = 0;
|
||||
int i;
|
||||
|
||||
if (!sctx->job.job_id) {
|
||||
// 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 */
|
||||
switch (opt_algo) {
|
||||
case ALGO_DECRED:
|
||||
// getwork over stratum, getwork merkle + header passed in coinb1
|
||||
memcpy(merkle_root, sctx->job.coinbase, 32);
|
||||
headersize = min((int)sctx->job.coinbase_size - 32, sizeof(extraheader));
|
||||
memcpy(extraheader, &sctx->job.coinbase[32], headersize);
|
||||
// getwork over stratum, no merkle to generate
|
||||
break;
|
||||
case ALGO_HEAVY:
|
||||
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);
|
||||
if (opt_algo == ALGO_HEAVY || opt_algo == ALGO_MJOLLNIR)
|
||||
heavycoin_hash(merkle_root, merkle_root, 64);
|
||||
else if (!headersize)
|
||||
else
|
||||
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);
|
||||
for (i = 0; i < 8; 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) {
|
||||
for (i = 0; i < 8; i++) // prevhash
|
||||
for (i = 0; i < 8; i++) // reversed prevhash
|
||||
work->data[1 + i] = swab32(work->data[1 + i]);
|
||||
for (i = 0; i < 8; i++) // merkle
|
||||
work->data[9 + i] = swab32(work->data[9 + i]);
|
||||
for (i = 0; i < headersize/4; i++) // header
|
||||
work->data[17 + i] = extraheader[i];
|
||||
// decred header (coinb1) [merkle...nonce]
|
||||
memcpy(&work->data[9], sctx->job.coinbase, 112);
|
||||
// extradata
|
||||
uint32_t* extradata = (uint32_t*) sctx->xnonce1;
|
||||
for (i = 0; i < sctx->xnonce1_size/4; i++)
|
||||
work->data[36 + i] = extradata[i];
|
||||
for (i = 36 + sctx->xnonce1_size/4; i < 45; i++)
|
||||
work->data[i] = 0;
|
||||
work->data[37] = (rand()*4) << 8;
|
||||
if (sctx->xnonce1_size > sizeof(work->data)-(36*4)) {
|
||||
// should never happen...
|
||||
applog(LOG_ERR, "extranonce size overflow!");
|
||||
sctx->xnonce1_size = sizeof(work->data)-(36*4);
|
||||
}
|
||||
memcpy(&work->data[36], sctx->xnonce1, sctx->xnonce1_size);
|
||||
work->data[37] = (rand()*4) << 8; // random work data
|
||||
sctx->job.height = work->data[32];
|
||||
//applog_hex(work->data, 180);
|
||||
} 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[18] = le32dec(sctx->job.nbits);
|
||||
work->data[20] = 0x80000000;
|
||||
|
Loading…
Reference in New Issue
Block a user