Changeset View
Changeset View
Standalone View
Standalone View
src/miner.cpp
Show First 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | |||||
bool BlockAssembler::SkipMapTxEntry( | bool BlockAssembler::SkipMapTxEntry( | ||||
CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, | CTxMemPool::txiter it, indexed_modified_transaction_set &mapModifiedTx, | ||||
CTxMemPool::setEntries &failedTx) { | CTxMemPool::setEntries &failedTx) { | ||||
assert(it != mempool->mapTx.end()); | assert(it != mempool->mapTx.end()); | ||||
return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it); | return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it); | ||||
} | } | ||||
void BlockAssembler::SortForBlock( | void BlockAssembler::SortForBlock( | ||||
const CTxMemPool::setEntries &package, CTxMemPool::txiter entry, | const CTxMemPool::setEntries &package, | ||||
std::vector<CTxMemPool::txiter> &sortedEntries) { | std::vector<CTxMemPool::txiter> &sortedEntries) { | ||||
// Sort package by ancestor count. If a transaction A depends on transaction | // Sort package by ancestor count. If a transaction A depends on transaction | ||||
// B, then A's ancestor count must be greater than B's. So this is | // B, then A's ancestor count must be greater than B's. So this is | ||||
// sufficient to validly order the transactions for block inclusion. | // sufficient to validly order the transactions for block inclusion. | ||||
sortedEntries.clear(); | sortedEntries.clear(); | ||||
sortedEntries.insert(sortedEntries.begin(), package.begin(), package.end()); | sortedEntries.insert(sortedEntries.begin(), package.begin(), package.end()); | ||||
std::sort(sortedEntries.begin(), sortedEntries.end(), | std::sort(sortedEntries.begin(), sortedEntries.end(), | ||||
CompareTxIterByAncestorCount()); | CompareTxIterByAncestorCount()); | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | while (mi != mempool->mapTx.get<ancestor_score>().end() || | ||||
continue; | continue; | ||||
} | } | ||||
// This transaction will make it in; reset the failed counter. | // This transaction will make it in; reset the failed counter. | ||||
nConsecutiveFailed = 0; | nConsecutiveFailed = 0; | ||||
// Package can be added. Sort the entries in a valid order. | // Package can be added. Sort the entries in a valid order. | ||||
std::vector<CTxMemPool::txiter> sortedEntries; | std::vector<CTxMemPool::txiter> sortedEntries; | ||||
SortForBlock(ancestors, iter, sortedEntries); | SortForBlock(ancestors, sortedEntries); | ||||
for (auto &entry : sortedEntries) { | for (auto &entry : sortedEntries) { | ||||
AddToBlock(entry); | AddToBlock(entry); | ||||
// Erase from the modified set, if present | // Erase from the modified set, if present | ||||
mapModifiedTx.erase(entry); | mapModifiedTx.erase(entry); | ||||
} | } | ||||
++nPackagesSelected; | ++nPackagesSelected; | ||||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |