MCPcopy Create free account
hub / github.com/ElementsProject/elements / IncrementExtraNonce

Function IncrementExtraNonce

src/node/miner.cpp:520–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518}
519
520void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
521{
522 // Update nExtraNonce
523 static uint256 hashPrevBlock;
524 if (hashPrevBlock != pblock->hashPrevBlock) {
525 nExtraNonce = 0;
526 hashPrevBlock = pblock->hashPrevBlock;
527 }
528 ++nExtraNonce;
529 unsigned int nHeight = pindexPrev->nHeight + 1; // Height first in coinbase required for block.version=2
530 CMutableTransaction txCoinbase(*pblock->vtx[0]);
531 txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce));
532 assert(txCoinbase.vin[0].scriptSig.size() <= 100);
533
534 pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
535 pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
536}
537} // namespace node

Callers 3

CreateBlockMethod · 0.85
GenerateBlockFunction · 0.85
getnewblockhexFunction · 0.85

Calls 5

BlockMerkleRootFunction · 0.85
CScriptClass · 0.70
CScriptNumClass · 0.50
MakeTransactionRefFunction · 0.50
sizeMethod · 0.45

Tested by 1

CreateBlockMethod · 0.68