aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorTheCharlatan <seb.kung@gmail.com>2023-09-01 21:36:54 +0200
committerTheCharlatan <seb.kung@gmail.com>2023-11-10 16:44:44 +0100
commit55b0939cab49d50ca5bc59105b669e379d5e7f6c (patch)
treeffb1ab68304a308061af54a4a9e1cd13bca3c35d /src/txmempool.cpp
parenta03aef9cec35b0d03aa63d7e8093f0420cd4b40b (diff)
scripted-diff: rename vTxHashes to txns_randomized
-BEGIN VERIFY SCRIPT- git grep -l "vTxHashesIdx" src | xargs sed -i "s/vTxHashesIdx/idx_randomized/g" git grep -l "vTxHashes" src | xargs sed -i "s/vTxHashes/txns_randomized/g" -END VERIFY SCRIPT-
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 14f4d3c032..efcb77f47c 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -480,8 +480,8 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
minerPolicyEstimator->processTransaction(entry, validFeeEstimate);
}
- vTxHashes.emplace_back(newit->GetSharedTx());
- newit->vTxHashesIdx = vTxHashes.size() - 1;
+ txns_randomized.emplace_back(newit->GetSharedTx());
+ newit->idx_randomized = txns_randomized.size() - 1;
TRACE3(mempool, added,
entry.GetTx().GetHash().data(),
@@ -517,16 +517,16 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
RemoveUnbroadcastTx(hash, true /* add logging because unchecked */ );
- if (vTxHashes.size() > 1) {
- // Update vTxHashesIdx of the to-be-moved entry.
- Assert(GetEntry(vTxHashes.back()->GetHash()))->vTxHashesIdx = it->vTxHashesIdx;
- // Remove entry from vTxHashes by replacing it with the back and deleting the back.
- vTxHashes[it->vTxHashesIdx] = std::move(vTxHashes.back());
- vTxHashes.pop_back();
- if (vTxHashes.size() * 2 < vTxHashes.capacity())
- vTxHashes.shrink_to_fit();
+ if (txns_randomized.size() > 1) {
+ // Update idx_randomized of the to-be-moved entry.
+ Assert(GetEntry(txns_randomized.back()->GetHash()))->idx_randomized = it->idx_randomized;
+ // Remove entry from txns_randomized by replacing it with the back and deleting the back.
+ txns_randomized[it->idx_randomized] = std::move(txns_randomized.back());
+ txns_randomized.pop_back();
+ if (txns_randomized.size() * 2 < txns_randomized.capacity())
+ txns_randomized.shrink_to_fit();
} else
- vTxHashes.clear();
+ txns_randomized.clear();
totalTxSize -= it->GetTxSize();
m_total_fee -= it->GetFee();
@@ -1054,7 +1054,7 @@ void CCoinsViewMemPool::Reset()
size_t CTxMemPool::DynamicMemoryUsage() const {
LOCK(cs);
// Estimate the overhead of mapTx to be 15 pointers + an allocation, as no exact formula for boost::multi_index_contained is implemented.
- return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(vTxHashes) + cachedInnerUsage;
+ return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(txns_randomized) + cachedInnerUsage;
}
void CTxMemPool::RemoveUnbroadcastTx(const uint256& txid, const bool unchecked) {