|
|
@ -338,66 +338,6 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void BlockAssembler::addScoreTxs() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
std::priority_queue<CTxMemPool::txiter, std::vector<CTxMemPool::txiter>, ScoreCompare> clearedTxs; |
|
|
|
|
|
|
|
CTxMemPool::setEntries waitSet; |
|
|
|
|
|
|
|
CTxMemPool::indexed_transaction_set::index<mining_score>::type::iterator mi = mempool.mapTx.get<mining_score>().begin(); |
|
|
|
|
|
|
|
CTxMemPool::txiter iter; |
|
|
|
|
|
|
|
while (!blockFinished && (mi != mempool.mapTx.get<mining_score>().end() || !clearedTxs.empty())) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// If no txs that were previously postponed are available to try
|
|
|
|
|
|
|
|
// again, then try the next highest score tx
|
|
|
|
|
|
|
|
if (clearedTxs.empty()) { |
|
|
|
|
|
|
|
iter = mempool.mapTx.project<0>(mi); |
|
|
|
|
|
|
|
mi++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// If a previously postponed tx is available to try again, then it
|
|
|
|
|
|
|
|
// has higher score than all untried so far txs
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
iter = clearedTxs.top(); |
|
|
|
|
|
|
|
clearedTxs.pop(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If tx already in block, skip (added by addPriorityTxs)
|
|
|
|
|
|
|
|
if (inBlock.count(iter)) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cannot accept witness transactions into a non-witness block
|
|
|
|
|
|
|
|
if (!fIncludeWitness && !iter->GetTx().wit.IsNull()) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If tx is dependent on other mempool txs which haven't yet been included
|
|
|
|
|
|
|
|
// then put it in the waitSet
|
|
|
|
|
|
|
|
if (isStillDependent(iter)) { |
|
|
|
|
|
|
|
waitSet.insert(iter); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the fee rate is below the min fee rate for mining, then we're done
|
|
|
|
|
|
|
|
// adding txs based on score (fee rate)
|
|
|
|
|
|
|
|
if (iter->GetModifiedFee() < ::minRelayTxFee.GetFee(iter->GetTxSize()) && nBlockSize >= nBlockMinSize) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If this tx fits in the block add it, otherwise keep looping
|
|
|
|
|
|
|
|
if (TestForBlock(iter)) { |
|
|
|
|
|
|
|
AddToBlock(iter); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This tx was successfully added, so
|
|
|
|
|
|
|
|
// add transactions that depend on this one to the priority queue to try again
|
|
|
|
|
|
|
|
BOOST_FOREACH(CTxMemPool::txiter child, mempool.GetMemPoolChildren(iter)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (waitSet.count(child)) { |
|
|
|
|
|
|
|
clearedTxs.push(child); |
|
|
|
|
|
|
|
waitSet.erase(child); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded, |
|
|
|
void BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded, |
|
|
|
indexed_modified_transaction_set &mapModifiedTx) |
|
|
|
indexed_modified_transaction_set &mapModifiedTx) |
|
|
|
{ |
|
|
|
{ |
|
|
|