Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | BlockAssembler::CreateNewBlock(const CScript &scriptPubKeyIn) { | ||||
// Fill in header. | // Fill in header. | ||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash(); | pblock->hashPrevBlock = pindexPrev->GetBlockHash(); | ||||
UpdateTime(pblock, consensusParams, pindexPrev); | UpdateTime(pblock, consensusParams, pindexPrev); | ||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); | pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); | ||||
pblock->nNonce = 0; | pblock->nNonce = 0; | ||||
pblocktemplate->entries[0].sigOpCount = 0; | pblocktemplate->entries[0].sigOpCount = 0; | ||||
CValidationState state; | BlockValidationState state; | ||||
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, | if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, | ||||
BlockValidationOptions(nMaxGeneratedBlockSize) | BlockValidationOptions(nMaxGeneratedBlockSize) | ||||
.withCheckPoW(false) | .withCheckPoW(false) | ||||
.withCheckMerkleRoot(false))) { | .withCheckMerkleRoot(false))) { | ||||
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", | throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", | ||||
__func__, | __func__, | ||||
FormatStateMessage(state))); | FormatStateMessage(state))); | ||||
} | } | ||||
Show All 39 Lines | |||||
* Perform transaction-level checks before adding to block: | * Perform transaction-level checks before adding to block: | ||||
* - Transaction finality (locktime) | * - Transaction finality (locktime) | ||||
* - Serialized size (in case -blockmaxsize is in use) | * - Serialized size (in case -blockmaxsize is in use) | ||||
*/ | */ | ||||
bool BlockAssembler::TestPackageTransactions( | bool BlockAssembler::TestPackageTransactions( | ||||
const CTxMemPool::setEntries &package) { | const CTxMemPool::setEntries &package) { | ||||
uint64_t nPotentialBlockSize = nBlockSize; | uint64_t nPotentialBlockSize = nBlockSize; | ||||
for (CTxMemPool::txiter it : package) { | for (CTxMemPool::txiter it : package) { | ||||
CValidationState state; | TxValidationState state; | ||||
if (!ContextualCheckTransaction(chainparams.GetConsensus(), it->GetTx(), | if (!ContextualCheckTransaction(chainparams.GetConsensus(), it->GetTx(), | ||||
state, nHeight, nLockTimeCutoff, | state, nHeight, nLockTimeCutoff, | ||||
nMedianTimePast)) { | nMedianTimePast)) { | ||||
return false; | return false; | ||||
} | } | ||||
uint64_t nTxSize = ::GetSerializeSize(it->GetTx(), PROTOCOL_VERSION); | uint64_t nTxSize = ::GetSerializeSize(it->GetTx(), PROTOCOL_VERSION); | ||||
if (nPotentialBlockSize + nTxSize >= nMaxGeneratedBlockSize) { | if (nPotentialBlockSize + nTxSize >= nMaxGeneratedBlockSize) { | ||||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |