aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2016-06-14 23:59:03 -0700
committerMatt Corallo <git@bluematt.me>2016-06-19 23:06:55 -0700
commit811902649d6aaddd886cb39b83aa69adf7b441bd (patch)
tree86410076db666aa134ff738b98d5ef260763ab3d /src/txmempool.cpp
parent678ee9793f6279c07b57c22c3cce983ab1e069d0 (diff)
downloadbitcoin-811902649d6aaddd886cb39b83aa69adf7b441bd.tar.xz
Provide a flat list of txid/terators to txn in CTxMemPool
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 18c54b08bc..ead28546de 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -438,6 +438,9 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
totalTxSize += entry.GetTxSize();
minerPolicyEstimator->processTransaction(entry, fCurrentEstimate);
+ vTxHashes.emplace_back(hash, newit);
+ newit->vTxHashesIdx = vTxHashes.size() - 1;
+
return true;
}
@@ -447,6 +450,15 @@ void CTxMemPool::removeUnchecked(txiter it)
BOOST_FOREACH(const CTxIn& txin, it->GetTx().vin)
mapNextTx.erase(txin.prevout);
+ if (vTxHashes.size() > 1) {
+ vTxHashes[it->vTxHashesIdx] = std::move(vTxHashes.back());
+ vTxHashes[it->vTxHashesIdx].second->vTxHashesIdx = it->vTxHashesIdx;
+ vTxHashes.pop_back();
+ if (vTxHashes.size() * 2 < vTxHashes.capacity())
+ vTxHashes.shrink_to_fit();
+ } else
+ vTxHashes.clear();
+
totalTxSize -= it->GetTxSize();
cachedInnerUsage -= it->DynamicMemoryUsage();
cachedInnerUsage -= memusage::DynamicUsage(mapLinks[it].parents) + memusage::DynamicUsage(mapLinks[it].children);
@@ -965,7 +977,7 @@ bool CCoinsViewMemPool::HaveCoins(const uint256 &txid) const {
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(mapLinks) + cachedInnerUsage;
+ return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(mapLinks) + memusage::DynamicUsage(vTxHashes) + cachedInnerUsage;
}
void CTxMemPool::RemoveStaged(setEntries &stage, bool updateDescendants) {