Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/node/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost
// - transaction finality (locktime)
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package) const
{
for (CTxMemPool::txiter it : package) {
for (const CTxMemPool::txiter& it : package) {
if (!IsFinalTx(it->GetTx(), nHeight, m_lock_time_cutoff)) {
return false;
}
Expand Down Expand Up @@ -248,11 +248,11 @@ static int UpdatePackagesForAdded(const CTxMemPool& mempool,
AssertLockHeld(mempool.cs);

int nDescendantsUpdated = 0;
for (CTxMemPool::txiter it : alreadyAdded) {
for (const CTxMemPool::txiter& it : alreadyAdded) {
CTxMemPool::setEntries descendants;
mempool.CalculateDescendants(it, descendants);
// Insert all descendants (not yet in block) into the modified set
for (CTxMemPool::txiter desc : descendants) {
for (const CTxMemPool::txiter& desc : descendants) {
if (alreadyAdded.count(desc)) {
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/policy/rbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool)
auto ancestors{pool.AssumeCalculateMemPoolAncestors(__func__, entry, CTxMemPool::Limits::NoLimits(),
/*fSearchForParents=*/false)};

for (CTxMemPool::txiter it : ancestors) {
for (const CTxMemPool::txiter& it : ancestors) {
if (SignalsOptInRBF(it->GetTx())) {
return RBFTransactionState::REPLACEABLE_BIP125;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx,
}
}
// Calculate the set of all transactions that would have to be evicted.
for (CTxMemPool::txiter it : iters_conflicting) {
for (const CTxMemPool::txiter& it : iters_conflicting) {
pool.CalculateDescendants(it, all_conflicts);
}
return std::nullopt;
Expand Down Expand Up @@ -117,7 +117,7 @@ std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries&
const std::set<uint256>& direct_conflicts,
const uint256& txid)
{
for (CTxMemPool::txiter ancestorIt : ancestors) {
for (const CTxMemPool::txiter& ancestorIt : ancestors) {
const uint256& hashAncestor = ancestorIt->GetTx().GetHash();
if (direct_conflicts.count(hashAncestor)) {
return strprintf("%s spends conflicting transaction %s",
Expand Down
8 changes: 4 additions & 4 deletions src/rpc/mempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,13 @@ static RPCHelpMan getmempoolancestors()

if (!fVerbose) {
UniValue o(UniValue::VARR);
for (CTxMemPool::txiter ancestorIt : ancestors) {
for (const CTxMemPool::txiter& ancestorIt : ancestors) {
o.push_back(ancestorIt->GetTx().GetHash().ToString());
}
return o;
} else {
UniValue o(UniValue::VOBJ);
for (CTxMemPool::txiter ancestorIt : ancestors) {
for (const CTxMemPool::txiter& ancestorIt : ancestors) {
const CTxMemPoolEntry &e = *ancestorIt;
const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
Expand Down Expand Up @@ -534,14 +534,14 @@ static RPCHelpMan getmempooldescendants()

if (!fVerbose) {
UniValue o(UniValue::VARR);
for (CTxMemPool::txiter descendantIt : setDescendants) {
for (const CTxMemPool::txiter& descendantIt : setDescendants) {
o.push_back(descendantIt->GetTx().GetHash().ToString());
}

return o;
} else {
UniValue o(UniValue::VOBJ);
for (CTxMemPool::txiter descendantIt : setDescendants) {
for (const CTxMemPool::txiter& descendantIt : setDescendants) {
const CTxMemPoolEntry &e = *descendantIt;
const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ);
Expand Down
34 changes: 17 additions & 17 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
if (cacheIt != cachedDescendants.end()) {
// We've already calculated this one, just add the entries for this set
// but don't traverse again.
for (txiter cacheEntry : cacheIt->second) {
for (const txiter& cacheEntry : cacheIt->second) {
descendants.insert(*cacheEntry);
}
} else if (!descendants.count(childEntry)) {
Expand Down Expand Up @@ -279,7 +279,7 @@ void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors
const int64_t updateCount = (add ? 1 : -1);
const int64_t updateSize = updateCount * it->GetTxSize();
const CAmount updateFee = updateCount * it->GetModifiedFee();
for (txiter ancestorIt : setAncestors) {
for (const txiter& ancestorIt : setAncestors) {
mapTx.modify(ancestorIt, [=](CTxMemPoolEntry& e) { e.UpdateDescendantState(updateSize, updateFee, updateCount); });
}
}
Expand All @@ -290,7 +290,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto
int64_t updateSize = 0;
CAmount updateFee = 0;
int64_t updateSigOpsCost = 0;
for (txiter ancestorIt : setAncestors) {
for (const txiter& ancestorIt : setAncestors) {
updateSize += ancestorIt->GetTxSize();
updateFee += ancestorIt->GetModifiedFee();
updateSigOpsCost += ancestorIt->GetSigOpCost();
Expand All @@ -317,19 +317,19 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
// Here we only update statistics and not data in CTxMemPool::Parents
// and CTxMemPoolEntry::Children (which we need to preserve until we're
// finished with all operations that need to traverse the mempool).
for (txiter removeIt : entriesToRemove) {
for (const 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();
for (txiter dit : setDescendants) {
for (const txiter& dit : setDescendants) {
mapTx.modify(dit, [=](CTxMemPoolEntry& e){ e.UpdateAncestorState(modifySize, modifyFee, -1, modifySigOps); });
}
}
}
for (txiter removeIt : entriesToRemove) {
for (const txiter& removeIt : entriesToRemove) {
const CTxMemPoolEntry &entry = *removeIt;
// Since this is a tx that is already in the mempool, we can call CMPA
// with fSearchForParents = false. If the mempool is in a consistent
Expand Down Expand Up @@ -358,7 +358,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 CTxMemPoolEntry::m_parents
// for each direct child of a transaction being removed).
for (txiter removeIt : entriesToRemove) {
for (const txiter& removeIt : entriesToRemove) {
UpdateChildrenForRemoval(removeIt);
}
}
Expand Down Expand Up @@ -571,7 +571,7 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, MemPoolRemovalReaso
}
}
setEntries setAllRemoves;
for (txiter it : txToRemove) {
for (const txiter& it : txToRemove) {
CalculateDescendants(it, setAllRemoves);
}

Expand All @@ -589,7 +589,7 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check
if (check_final_and_mature(it)) txToRemove.insert(it);
}
setEntries setAllRemoves;
for (txiter it : txToRemove) {
for (const txiter& it : txToRemove) {
CalculateDescendants(it, setAllRemoves);
}
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
Expand Down Expand Up @@ -701,7 +701,7 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
CAmount nFeesCheck = it->GetModifiedFee();
int64_t nSigOpCheck = it->GetSigOpCost();

for (txiter ancestorIt : ancestors) {
for (const txiter& ancestorIt : ancestors) {
nSizeCheck += ancestorIt->GetTxSize();
nFeesCheck += ancestorIt->GetModifiedFee();
nSigOpCheck += ancestorIt->GetSigOpCost();
Expand Down Expand Up @@ -805,7 +805,7 @@ void CTxMemPool::queryHashes(std::vector<uint256>& vtxid) const
vtxid.clear();
vtxid.reserve(mapTx.size());

for (auto it : iters) {
for (const auto& it : iters) {
vtxid.push_back(it->GetTx().GetHash());
}
}
Expand All @@ -821,7 +821,7 @@ std::vector<TxMempoolInfo> CTxMemPool::infoAll() const

std::vector<TxMempoolInfo> ret;
ret.reserve(mapTx.size());
for (auto it : iters) {
for (const auto& it : iters) {
ret.push_back(GetInfo(it));
}

Expand Down Expand Up @@ -857,14 +857,14 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
mapTx.modify(it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(nFeeDelta); });
// Now update all ancestors' modified fees with descendants
auto ancestors{AssumeCalculateMemPoolAncestors(__func__, *it, Limits::NoLimits(), /*fSearchForParents=*/false)};
for (txiter ancestorIt : ancestors) {
for (const txiter& ancestorIt : ancestors) {
mapTx.modify(ancestorIt, [=](CTxMemPoolEntry& e){ e.UpdateDescendantState(0, nFeeDelta, 0);});
}
// Now update all descendants' modified fees with ancestors
setEntries setDescendants;
CalculateDescendants(it, setDescendants);
setDescendants.erase(it);
for (txiter descendantIt : setDescendants) {
for (const txiter& descendantIt : setDescendants) {
mapTx.modify(descendantIt, [=](CTxMemPoolEntry& e){ e.UpdateAncestorState(0, nFeeDelta, 0, 0); });
}
++nTransactionsUpdated;
Expand Down Expand Up @@ -970,7 +970,7 @@ void CTxMemPool::RemoveUnbroadcastTx(const uint256& txid, const bool unchecked)
void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason) {
AssertLockHeld(cs);
UpdateForRemoveFromMempool(stage, updateDescendants);
for (txiter it : stage) {
for (const txiter& it : stage) {
removeUnchecked(it, reason);
}
}
Expand All @@ -985,7 +985,7 @@ int CTxMemPool::Expire(std::chrono::seconds time)
it++;
}
setEntries stage;
for (txiter removeit : toremove) {
for (const txiter& removeit : toremove) {
CalculateDescendants(removeit, stage);
}
RemoveStaged(stage, false, MemPoolRemovalReason::EXPIRY);
Expand Down Expand Up @@ -1076,7 +1076,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<COutPoint>* pvNoSpends
std::vector<CTransaction> txn;
if (pvNoSpendsRemaining) {
txn.reserve(stage.size());
for (txiter iter : stage)
for (const txiter& iter : stage)
txn.push_back(iter->GetTx());
}
RemoveStaged(stage, false, MemPoolRemovalReason::SIZELIMIT);
Expand Down
4 changes: 2 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ bool MemPoolAccept::ReplacementChecks(Workspace& ws)
}
// Check if it's economically rational to mine this transaction rather than the ones it
// replaces and pays for its own relay fees. Enforce Rules #3 and #4.
for (CTxMemPool::txiter it : ws.m_all_conflicting) {
for (const CTxMemPool::txiter& it : ws.m_all_conflicting) {
ws.m_conflicting_fees += it->GetModifiedFee();
ws.m_conflicting_size += it->GetTxSize();
}
Expand Down Expand Up @@ -1068,7 +1068,7 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
std::unique_ptr<CTxMemPoolEntry>& entry = ws.m_entry;

// Remove conflicting transactions from the mempool
for (CTxMemPool::txiter it : ws.m_all_conflicting)
for (const CTxMemPool::txiter& it : ws.m_all_conflicting)
{
LogPrint(BCLog::MEMPOOL, "replacing tx %s with %s for %s additional fees, %d delta bytes\n",
it->GetTx().GetHash().ToString(),
Expand Down