Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 688 Lines • ▼ Show 20 Lines | void IncrementExtraNonce(const Config &config, CBlock *pblock, | ||||
++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 = | ||||
(CScript() << nHeight << CScriptNum(nExtraNonce) | (CScript() << nHeight << CScriptNum(nExtraNonce) | ||||
<< getExcessiveBlockSizeSig(config)) + | << getExcessiveBlockSizeSig(config)) + | ||||
COINBASE_FLAGS; | COINBASE_FLAGS; | ||||
// Make sure the coinbase is big enough. | |||||
uint64_t coinbaseSize = | |||||
::GetSerializeSize(txCoinbase, SER_NETWORK, PROTOCOL_VERSION); | |||||
if (coinbaseSize < MIN_TX_SIZE) { | |||||
txCoinbase.vin[0].scriptSig | |||||
<< std::vector<uint8_t>(MIN_TX_SIZE - coinbaseSize - 1); | |||||
} | |||||
assert(txCoinbase.vin[0].scriptSig.size() <= MAX_COINBASE_SCRIPTSIG_SIZE); | assert(txCoinbase.vin[0].scriptSig.size() <= MAX_COINBASE_SCRIPTSIG_SIZE); | ||||
assert(::GetSerializeSize(txCoinbase, SER_NETWORK, PROTOCOL_VERSION) >= | |||||
MIN_TX_SIZE); | |||||
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase)); | pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase)); | ||||
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); | pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); | ||||
} | } |