Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 543 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, | void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, | ||||
uint64_t nExcessiveBlockSize, | uint64_t nExcessiveBlockSize, | ||||
unsigned int &nExtraNonce) { | unsigned int &nExtraNonce) { | ||||
// Update nExtraNonce | // Update nExtraNonce | ||||
static uint256 hashPrevBlock; | static uint256 hashPrevBlock; | ||||
if (hashPrevBlock != pblock->hashPrevBlock) { | if (hashPrevBlock != pblock->hashPrevBlock) { | ||||
nExtraNonce = 0; | FastRandomContext rng; | ||||
nExtraNonce = rng.rand32(); | |||||
hashPrevBlock = pblock->hashPrevBlock; | hashPrevBlock = pblock->hashPrevBlock; | ||||
} | } | ||||
++nExtraNonce; | ++nExtraNonce; | ||||
// Height first in coinbase required for block.version=2 | // Height first in coinbase required for block.version=2 | ||||
unsigned int nHeight = pindexPrev->nHeight + 1; | unsigned int nHeight = pindexPrev->nHeight + 1; | ||||
CMutableTransaction txCoinbase(*pblock->vtx[0]); | CMutableTransaction txCoinbase(*pblock->vtx[0]); | ||||
txCoinbase.vin[0].scriptSig = | txCoinbase.vin[0].scriptSig = | ||||
Show All 16 Lines |