@@ -438,6 +438,9 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
438438 totalTxSize += entry.GetTxSize ();
439439 minerPolicyEstimator->processTransaction (entry, fCurrentEstimate );
440440
441+ vTxHashes.emplace_back (hash, newit);
442+ newit->vTxHashesIdx = vTxHashes.size () - 1 ;
443+
441444 return true ;
442445}
443446
@@ -447,6 +450,15 @@ void CTxMemPool::removeUnchecked(txiter it)
447450 BOOST_FOREACH (const CTxIn& txin, it->GetTx ().vin )
448451 mapNextTx.erase (txin.prevout );
449452
453+ if (vTxHashes.size () > 1 ) {
454+ vTxHashes[it->vTxHashesIdx ] = std::move (vTxHashes.back ());
455+ vTxHashes[it->vTxHashesIdx ].second ->vTxHashesIdx = it->vTxHashesIdx ;
456+ vTxHashes.pop_back ();
457+ if (vTxHashes.size () * 2 < vTxHashes.capacity ())
458+ vTxHashes.shrink_to_fit ();
459+ } else
460+ vTxHashes.clear ();
461+
450462 totalTxSize -= it->GetTxSize ();
451463 cachedInnerUsage -= it->DynamicMemoryUsage ();
452464 cachedInnerUsage -= memusage::DynamicUsage (mapLinks[it].parents ) + memusage::DynamicUsage (mapLinks[it].children );
@@ -965,7 +977,7 @@ bool CCoinsViewMemPool::HaveCoins(const uint256 &txid) const {
965977size_t CTxMemPool::DynamicMemoryUsage () const {
966978 LOCK (cs);
967979 // Estimate the overhead of mapTx to be 15 pointers + an allocation, as no exact formula for boost::multi_index_contained is implemented.
968- return memusage::MallocUsage (sizeof (CTxMemPoolEntry) + 15 * sizeof (void *)) * mapTx.size () + memusage::DynamicUsage (mapNextTx) + memusage::DynamicUsage (mapDeltas) + memusage::DynamicUsage (mapLinks) + cachedInnerUsage;
980+ return memusage::MallocUsage (sizeof (CTxMemPoolEntry) + 15 * sizeof (void *)) * mapTx.size () + memusage::DynamicUsage (mapNextTx) + memusage::DynamicUsage (mapDeltas) + memusage::DynamicUsage (mapLinks) + memusage::DynamicUsage (vTxHashes) + cachedInnerUsage;
969981}
970982
971983void CTxMemPool::RemoveStaged (setEntries &stage, bool updateDescendants) {
0 commit comments