Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | for (const CTxMemPool::txiter it : package) { | ||||
nPotentialBlockSize += nTxSize; | nPotentialBlockSize += nTxSize; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
BlockAssembler::TestForBlockResult | BlockAssembler::TestForBlockResult | ||||
BlockAssembler::TestForBlock(CTxMemPool::txiter it) { | BlockAssembler::TestForBlock(const Config &config, CTxMemPool::txiter it) { | ||||
auto blockSizeWithTx = | auto blockSizeWithTx = | ||||
nBlockSize + | nBlockSize + | ||||
::GetSerializeSize(it->GetTx(), SER_NETWORK, PROTOCOL_VERSION); | ::GetSerializeSize(it->GetTx(), SER_NETWORK, PROTOCOL_VERSION); | ||||
if (blockSizeWithTx >= nMaxGeneratedBlockSize) { | if (blockSizeWithTx >= nMaxGeneratedBlockSize) { | ||||
if (nBlockSize > nMaxGeneratedBlockSize - 100 || lastFewTxs > 50) { | if (nBlockSize > nMaxGeneratedBlockSize - 100 || lastFewTxs > 50) { | ||||
return TestForBlockResult::BlockFinished; | return TestForBlockResult::BlockFinished; | ||||
} | } | ||||
Show All 17 Lines | if (nBlockSigOps + it->GetSigOpCount() >= maxBlockSigOps) { | ||||
// Otherwise attempt to find another tx with fewer sigops to put in the | // Otherwise attempt to find another tx with fewer sigops to put in the | ||||
// block. | // block. | ||||
return TestForBlockResult::TXCantFit; | return TestForBlockResult::TXCantFit; | ||||
} | } | ||||
// Must check that lock times are still valid. This can be removed once MTP | // Must check that lock times are still valid. This can be removed once MTP | ||||
// is always enforced as long as reorgs keep the mempool consistent. | // is always enforced as long as reorgs keep the mempool consistent. | ||||
CValidationState state; | CValidationState state; | ||||
if (!ContextualCheckTransaction(*config, it->GetTx(), state, nHeight, | if (!ContextualCheckTransaction(config, it->GetTx(), state, nHeight, | ||||
nLockTimeCutoff, nMedianTimePast)) { | nLockTimeCutoff, nMedianTimePast)) { | ||||
return TestForBlockResult::TXCantFit; | return TestForBlockResult::TXCantFit; | ||||
} | } | ||||
return TestForBlockResult::TXFits; | return TestForBlockResult::TXFits; | ||||
} | } | ||||
void BlockAssembler::AddToBlock(CTxMemPool::txiter iter) { | void BlockAssembler::AddToBlock(CTxMemPool::txiter iter) { | ||||
▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | while (!vecPriority.empty()) { | ||||
// If tx is dependent on other mempool txs which haven't yet been | // If tx is dependent on other mempool txs which haven't yet been | ||||
// included then put it in the waitSet. | // included then put it in the waitSet. | ||||
if (isStillDependent(iter)) { | if (isStillDependent(iter)) { | ||||
waitPriMap.insert(std::make_pair(iter, actualPriority)); | waitPriMap.insert(std::make_pair(iter, actualPriority)); | ||||
continue; | continue; | ||||
} | } | ||||
TestForBlockResult testResult = TestForBlock(iter); | TestForBlockResult testResult = TestForBlock(config, iter); | ||||
// Break if the block is completed | // Break if the block is completed | ||||
if (testResult == TestForBlockResult::BlockFinished) { | if (testResult == TestForBlockResult::BlockFinished) { | ||||
break; | break; | ||||
} | } | ||||
// If this tx does not fit in the block, skip to next transaction. | // If this tx does not fit in the block, skip to next transaction. | ||||
if (testResult != TestForBlockResult::TXFits) { | if (testResult != TestForBlockResult::TXFits) { | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |