Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 556 Lines • ▼ Show 20 Lines | void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, | ||||
} | } | ||||
++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(nExcessiveBlockSize)) + | << getExcessiveBlockSizeSig(nExcessiveBlockSize)); | ||||
COINBASE_FLAGS; | |||||
// Make sure the coinbase is big enough. | // Make sure the coinbase is big enough. | ||||
uint64_t coinbaseSize = ::GetSerializeSize(txCoinbase, PROTOCOL_VERSION); | uint64_t coinbaseSize = ::GetSerializeSize(txCoinbase, PROTOCOL_VERSION); | ||||
if (coinbaseSize < MIN_TX_SIZE) { | if (coinbaseSize < MIN_TX_SIZE) { | ||||
txCoinbase.vin[0].scriptSig | txCoinbase.vin[0].scriptSig | ||||
<< std::vector<uint8_t>(MIN_TX_SIZE - coinbaseSize - 1); | << 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, PROTOCOL_VERSION) >= MIN_TX_SIZE); | assert(::GetSerializeSize(txCoinbase, 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); | ||||
} | } |