mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
miner: Absorb SkipMapTxEntry into addPackageTxs
SkipMapTxEntry is a short helper function that's only used in addPackageTxs, we can just inline it, keep the comments, and avoid the unnecessary interface and lock annotations.
This commit is contained in:
parent
345457b542
commit
f024578b3a
2 changed files with 19 additions and 24 deletions
|
@ -262,23 +262,6 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
|
||||||
return nDescendantsUpdated;
|
return nDescendantsUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip entries in mapTx that are already in a block or are present
|
|
||||||
// in mapModifiedTx (which implies that the mapTx ancestor state is
|
|
||||||
// stale due to ancestor inclusion in the block)
|
|
||||||
// Also skip transactions that we've already failed to add. This can happen if
|
|
||||||
// we consider a transaction in mapModifiedTx and it fails: we can then
|
|
||||||
// potentially consider it again while walking mapTx. It's currently
|
|
||||||
// guaranteed to fail again, but as a belt-and-suspenders check we put it in
|
|
||||||
// failedTx and avoid re-evaluation, since the re-evaluation would be using
|
|
||||||
// cached size/sigops/fee values that are not actually correct.
|
|
||||||
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx)
|
|
||||||
{
|
|
||||||
AssertLockHeld(m_mempool.cs);
|
|
||||||
|
|
||||||
assert(it != m_mempool.mapTx.end());
|
|
||||||
return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries)
|
void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries)
|
||||||
{
|
{
|
||||||
// Sort package by ancestor count
|
// Sort package by ancestor count
|
||||||
|
@ -321,11 +304,26 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
||||||
|
|
||||||
while (mi != m_mempool.mapTx.get<ancestor_score>().end() || !mapModifiedTx.empty()) {
|
while (mi != m_mempool.mapTx.get<ancestor_score>().end() || !mapModifiedTx.empty()) {
|
||||||
// First try to find a new transaction in mapTx to evaluate.
|
// First try to find a new transaction in mapTx to evaluate.
|
||||||
if (mi != m_mempool.mapTx.get<ancestor_score>().end() &&
|
//
|
||||||
SkipMapTxEntry(m_mempool.mapTx.project<0>(mi), mapModifiedTx, failedTx)) {
|
// Skip entries in mapTx that are already in a block or are present
|
||||||
|
// in mapModifiedTx (which implies that the mapTx ancestor state is
|
||||||
|
// stale due to ancestor inclusion in the block)
|
||||||
|
// Also skip transactions that we've already failed to add. This can happen if
|
||||||
|
// we consider a transaction in mapModifiedTx and it fails: we can then
|
||||||
|
// potentially consider it again while walking mapTx. It's currently
|
||||||
|
// guaranteed to fail again, but as a belt-and-suspenders check we put it in
|
||||||
|
// failedTx and avoid re-evaluation, since the re-evaluation would be using
|
||||||
|
// cached size/sigops/fee values that are not actually correct.
|
||||||
|
/** Return true if given transaction from mapTx has already been evaluated,
|
||||||
|
* or if the transaction's cached data in mapTx is incorrect. */
|
||||||
|
if (mi != m_mempool.mapTx.get<ancestor_score>().end()) {
|
||||||
|
auto it = m_mempool.mapTx.project<0>(mi);
|
||||||
|
assert(it != m_mempool.mapTx.end());
|
||||||
|
if (mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it)) {
|
||||||
++mi;
|
++mi;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now that mi is not stale, determine which transaction to evaluate:
|
// Now that mi is not stale, determine which transaction to evaluate:
|
||||||
// the next entry from mapTx, or the best from mapModifiedTx?
|
// the next entry from mapTx, or the best from mapModifiedTx?
|
||||||
|
|
|
@ -189,9 +189,6 @@ private:
|
||||||
* These checks should always succeed, and they're here
|
* These checks should always succeed, and they're here
|
||||||
* only as an extra check in case of suboptimal node configuration */
|
* only as an extra check in case of suboptimal node configuration */
|
||||||
bool TestPackageTransactions(const CTxMemPool::setEntries& package) const;
|
bool TestPackageTransactions(const CTxMemPool::setEntries& package) const;
|
||||||
/** Return true if given transaction from mapTx has already been evaluated,
|
|
||||||
* or if the transaction's cached data in mapTx is incorrect. */
|
|
||||||
bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
|
|
||||||
/** Sort the package in an order that is valid to appear in a block */
|
/** Sort the package in an order that is valid to appear in a block */
|
||||||
void SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries);
|
void SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries);
|
||||||
/** Add descendants of given transactions to mapModifiedTx with ancestor
|
/** Add descendants of given transactions to mapModifiedTx with ancestor
|
||||||
|
|
Loading…
Add table
Reference in a new issue