Browse Source

decred: allow custom extranonce sizes

the extranonce is already placed after header in job.coinbase
master
Tanguy Pruvot 9 years ago
parent
commit
a823cca7f9
  1. 1
      Algo256/vanilla.cu
  2. 14
      ccminer.cpp

1
Algo256/vanilla.cu

@ -393,6 +393,7 @@ extern "C" int scanhash_vanilla(int thr_id, struct work* work, uint32_t max_nonc
} }
rc = 2; rc = 2;
} }
pdata[21] = work->nonces[1];
#endif #endif
pdata[19] = work->nonces[0]; pdata[19] = work->nonces[0];
return rc; return rc;

14
ccminer.cpp

@ -1345,8 +1345,8 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
switch (opt_algo) { switch (opt_algo) {
case ALGO_DECRED: case ALGO_DECRED:
// getwork over stratum, getwork merkle + header passed in coinb1 // getwork over stratum, getwork merkle + header passed in coinb1
headersize = (int)sctx->job.coinbase_size - 32;
memcpy(merkle_root, sctx->job.coinbase, 32); memcpy(merkle_root, sctx->job.coinbase, 32);
headersize = min((int)sctx->job.coinbase_size - 32, sizeof(extraheader));
memcpy(extraheader, &sctx->job.coinbase[32], headersize); memcpy(extraheader, &sctx->job.coinbase[32], headersize);
break; break;
case ALGO_HEAVY: case ALGO_HEAVY:
@ -1385,18 +1385,16 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
work->data[9 + i] = be32dec((uint32_t *)merkle_root + i); work->data[9 + i] = be32dec((uint32_t *)merkle_root + i);
if (opt_algo == ALGO_DECRED) { if (opt_algo == ALGO_DECRED) {
uint32_t* extradata = (uint32_t*) sctx->xnonce1;
for (i = 0; i < 8; i++) // prevhash for (i = 0; i < 8; i++) // 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 for (i = 0; i < 8; i++) // merkle
work->data[9 + i] = swab32(work->data[9 + i]); work->data[9 + i] = swab32(work->data[9 + i]);
for (i = 0; i < headersize/4; i++) // header for (i = 0; i < headersize/4; i++) // header + extradata
work->data[17 + i] = le32dec(&extraheader[i]); work->data[17 + i] = extraheader[i];
for (i = 0; i < sctx->xnonce1_size/4; i++) // extradata // allow custom extranonce sizes
work->data[36 + i] = extradata[i]; for (i = 36 + sctx->xnonce1_size/4; i < 45; i++)
work->data[37] = (rand()*4) << 8;
for (int i=39; i < 45; i++)
work->data[i] = 0; work->data[i] = 0;
work->data[37] = (rand()*4) << 8;
sctx->job.height = work->data[32]; sctx->job.height = work->data[32];
//applog_hex(work->data, 180); //applog_hex(work->data, 180);
} else { } else {

Loading…
Cancel
Save