diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2017-06-13 17:55:46 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2017-06-13 18:05:58 -0700 |
commit | 1ad3d4e1261f4a444d982a1470c257c78233bda3 (patch) | |
tree | 228e740c5251770dc6f32a99c8be792b1ea5eda8 /src/txmempool.cpp | |
parent | fbf5d3ba15161f71cbb84a51c1703c22b651e8a9 (diff) | |
parent | 1238f13cf6ccf1177b66df735f360c61ae1dc20b (diff) |
Merge #10502: scripted-diff: Remove BOOST_FOREACH, Q_FOREACH and PAIRTYPE
1238f13cf scripted-diff: Remove PAIRTYPE (Jorge Timón)
18dc3c396 scripted-diff: Remove Q_FOREACH (Jorge Timón)
7c00c2672 scripted-diff: Fully remove BOOST_FOREACH (Jorge Timón)
a5410ac5e Small preparations for Q_FOREACH, PAIRTYPE and #include <boost/foreach.hpp> removal (Jorge Timón)
Tree-SHA512: d3ab4a173366402e7dcef31608977b757d4aa07abbbad2ee1bcbcfa311e994a4552f24e5a55272cb22c2dcf89a4b0495e02e9d9aceae4b08c0bab668f20e324c
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 17389db9f0..afafc695f4 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -73,12 +73,12 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendan setAllDescendants.insert(cit); stageEntries.erase(cit); const setEntries &setChildren = GetMemPoolChildren(cit); - BOOST_FOREACH(const txiter childEntry, setChildren) { + for (const txiter childEntry : setChildren) { cacheMap::iterator cacheIt = cachedDescendants.find(childEntry); if (cacheIt != cachedDescendants.end()) { // We've already calculated this one, just add the entries for this set // but don't traverse again. - BOOST_FOREACH(const txiter cacheEntry, cacheIt->second) { + for (const txiter cacheEntry : cacheIt->second) { setAllDescendants.insert(cacheEntry); } } else if (!setAllDescendants.count(childEntry)) { @@ -92,7 +92,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap &cachedDescendan int64_t modifySize = 0; CAmount modifyFee = 0; int64_t modifyCount = 0; - BOOST_FOREACH(txiter cit, setAllDescendants) { + for (txiter cit : setAllDescendants) { if (!setExclude.count(cit->GetTx().GetHash())) { modifySize += cit->GetTxSize(); modifyFee += cit->GetModifiedFee(); @@ -202,7 +202,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntr } const setEntries & setMemPoolParents = GetMemPoolParents(stageit); - BOOST_FOREACH(const txiter &phash, setMemPoolParents) { + for (const txiter &phash : setMemPoolParents) { // If this is a new ancestor, add it. if (setAncestors.count(phash) == 0) { parentHashes.insert(phash); @@ -221,13 +221,13 @@ void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors { setEntries parentIters = GetMemPoolParents(it); // add or remove this tx as a child of each parent - BOOST_FOREACH(txiter piter, parentIters) { + for (txiter piter : parentIters) { UpdateChild(piter, it, add); } const int64_t updateCount = (add ? 1 : -1); const int64_t updateSize = updateCount * it->GetTxSize(); const CAmount updateFee = updateCount * it->GetModifiedFee(); - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { mapTx.modify(ancestorIt, update_descendant_state(updateSize, updateFee, updateCount)); } } @@ -238,7 +238,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto int64_t updateSize = 0; CAmount updateFee = 0; int64_t updateSigOpsCost = 0; - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { updateSize += ancestorIt->GetTxSize(); updateFee += ancestorIt->GetModifiedFee(); updateSigOpsCost += ancestorIt->GetSigOpCost(); @@ -249,7 +249,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto void CTxMemPool::UpdateChildrenForRemoval(txiter it) { const setEntries &setMemPoolChildren = GetMemPoolChildren(it); - BOOST_FOREACH(txiter updateIt, setMemPoolChildren) { + for (txiter updateIt : setMemPoolChildren) { UpdateParent(updateIt, it, false); } } @@ -266,19 +266,19 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b // Here we only update statistics and not data in mapLinks (which // we need to preserve until we're finished with all operations that // need to traverse the mempool). - BOOST_FOREACH(txiter removeIt, entriesToRemove) { + for (txiter removeIt : entriesToRemove) { setEntries setDescendants; CalculateDescendants(removeIt, setDescendants); setDescendants.erase(removeIt); // don't update state for self int64_t modifySize = -((int64_t)removeIt->GetTxSize()); CAmount modifyFee = -removeIt->GetModifiedFee(); int modifySigOps = -removeIt->GetSigOpCost(); - BOOST_FOREACH(txiter dit, setDescendants) { + for (txiter dit : setDescendants) { mapTx.modify(dit, update_ancestor_state(modifySize, modifyFee, -1, modifySigOps)); } } } - BOOST_FOREACH(txiter removeIt, entriesToRemove) { + for (txiter removeIt : entriesToRemove) { setEntries setAncestors; const CTxMemPoolEntry &entry = *removeIt; std::string dummy; @@ -307,7 +307,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b // After updating all the ancestor sizes, we can now sever the link between each // transaction being removed and any mempool children (ie, update setMemPoolParents // for each direct child of a transaction being removed). - BOOST_FOREACH(txiter removeIt, entriesToRemove) { + for (txiter removeIt : entriesToRemove) { UpdateChildrenForRemoval(removeIt); } } @@ -401,7 +401,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, // to clean up the mess we're leaving here. // Update ancestors with information about this tx - BOOST_FOREACH (const uint256 &phash, setParentTransactions) { + for (const uint256 &phash : setParentTransactions) { txiter pit = mapTx.find(phash); if (pit != mapTx.end()) { UpdateParent(newit, pit, true); @@ -424,7 +424,7 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) { NotifyEntryRemoved(it->GetSharedTx(), reason); const uint256 hash = it->GetTx().GetHash(); - BOOST_FOREACH(const CTxIn& txin, it->GetTx().vin) + for (const CTxIn& txin : it->GetTx().vin) mapNextTx.erase(txin.prevout); if (vTxHashes.size() > 1) { @@ -466,7 +466,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries &setDescendants stage.erase(it); const setEntries &setChildren = GetMemPoolChildren(it); - BOOST_FOREACH(const txiter &childiter, setChildren) { + for (const txiter &childiter : setChildren) { if (!setDescendants.count(childiter)) { stage.insert(childiter); } @@ -498,7 +498,7 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReaso } } setEntries setAllRemoves; - BOOST_FOREACH(txiter it, txToRemove) { + for (txiter it : txToRemove) { CalculateDescendants(it, setAllRemoves); } @@ -520,7 +520,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem // So it's critical that we remove the tx and not depend on the LockPoints. txToRemove.insert(it); } else if (it->GetSpendsCoinbase()) { - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTxIn& txin : tx.vin) { indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); if (it2 != mapTx.end()) continue; @@ -547,7 +547,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx) { // Remove transactions which depend on inputs of tx, recursively LOCK(cs); - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { auto it = mapNextTx.find(txin.prevout); if (it != mapNextTx.end()) { const CTransaction &txConflict = *it->second; @@ -642,7 +642,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const setEntries setParentCheck; int64_t parentSizes = 0; int64_t parentSigOpCost = 0; - BOOST_FOREACH(const CTxIn &txin, tx.vin) { + for (const CTxIn &txin : tx.vin) { // Check that every mempool transaction's inputs refer to available coins, or other mempool tx's. indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash); if (it2 != mapTx.end()) { @@ -674,7 +674,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const CAmount nFeesCheck = it->GetModifiedFee(); int64_t nSigOpCheck = it->GetSigOpCost(); - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { nSizeCheck += ancestorIt->GetTxSize(); nFeesCheck += ancestorIt->GetModifiedFee(); nSigOpCheck += ancestorIt->GetSigOpCost(); @@ -848,14 +848,14 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD uint64_t nNoLimit = std::numeric_limits<uint64_t>::max(); std::string dummy; CalculateMemPoolAncestors(*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false); - BOOST_FOREACH(txiter ancestorIt, setAncestors) { + for (txiter ancestorIt : setAncestors) { mapTx.modify(ancestorIt, update_descendant_state(0, nFeeDelta, 0)); } // Now update all descendants' modified fees with ancestors setEntries setDescendants; CalculateDescendants(it, setDescendants); setDescendants.erase(it); - BOOST_FOREACH(txiter descendantIt, setDescendants) { + for (txiter descendantIt : setDescendants) { mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0)); } ++nTransactionsUpdated; @@ -919,7 +919,7 @@ size_t CTxMemPool::DynamicMemoryUsage() const { void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) { AssertLockHeld(cs); UpdateForRemoveFromMempool(stage, updateDescendants); - BOOST_FOREACH(const txiter& it, stage) { + for (const txiter& it : stage) { removeUnchecked(it, reason); } } @@ -933,7 +933,7 @@ int CTxMemPool::Expire(int64_t time) { it++; } setEntries stage; - BOOST_FOREACH(txiter removeit, toremove) { + for (txiter removeit : toremove) { CalculateDescendants(removeit, stage); } RemoveStaged(stage, false, MemPoolRemovalReason::EXPIRY); @@ -1042,13 +1042,13 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpends std::vector<CTransaction> txn; if (pvNoSpendsRemaining) { txn.reserve(stage.size()); - BOOST_FOREACH(txiter iter, stage) + for (txiter iter : stage) txn.push_back(iter->GetTx()); } RemoveStaged(stage, false, MemPoolRemovalReason::SIZELIMIT); if (pvNoSpendsRemaining) { - BOOST_FOREACH(const CTransaction& tx, txn) { - BOOST_FOREACH(const CTxIn& txin, tx.vin) { + for (const CTransaction& tx : txn) { + for (const CTxIn& txin : tx.vin) { if (exists(txin.prevout.hash)) continue; if (!mapNextTx.count(txin.prevout)) { pvNoSpendsRemaining->push_back(txin.prevout); |