@@ -438,6 +438,9 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
438
438
totalTxSize += entry.GetTxSize ();
439
439
minerPolicyEstimator->processTransaction (entry, fCurrentEstimate );
440
440
441
+ vTxHashes.emplace_back (hash, newit);
442
+ newit->vTxHashesIdx = vTxHashes.size () - 1 ;
443
+
441
444
return true ;
442
445
}
443
446
@@ -447,6 +450,15 @@ void CTxMemPool::removeUnchecked(txiter it)
447
450
BOOST_FOREACH (const CTxIn& txin, it->GetTx ().vin )
448
451
mapNextTx.erase (txin.prevout );
449
452
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
+
450
462
totalTxSize -= it->GetTxSize ();
451
463
cachedInnerUsage -= it->DynamicMemoryUsage ();
452
464
cachedInnerUsage -= memusage::DynamicUsage (mapLinks[it].parents ) + memusage::DynamicUsage (mapLinks[it].children );
@@ -965,7 +977,7 @@ bool CCoinsViewMemPool::HaveCoins(const uint256 &txid) const {
965
977
size_t CTxMemPool::DynamicMemoryUsage () const {
966
978
LOCK (cs);
967
979
// 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;
969
981
}
970
982
971
983
void CTxMemPool::RemoveStaged (setEntries &stage, bool updateDescendants) {
0 commit comments