@@ -393,6 +393,7 @@ void CTxMemPool::AddTransactionsUpdated(unsigned int n)
393
393
394
394
bool CTxMemPool::addUnchecked (const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate)
395
395
{
396
+ NotifyEntryAdded (entry.GetSharedTx ());
396
397
// Add to memory pool without checking anything.
397
398
// Used by main.cpp AcceptToMemoryPool(), which DOES do
398
399
// all the appropriate checks.
@@ -449,8 +450,9 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
449
450
return true ;
450
451
}
451
452
452
- void CTxMemPool::removeUnchecked (txiter it)
453
+ void CTxMemPool::removeUnchecked (txiter it, MemPoolRemovalReason reason )
453
454
{
455
+ NotifyEntryRemoved (it->GetSharedTx (), reason);
454
456
const uint256 hash = it->GetTx ().GetHash ();
455
457
BOOST_FOREACH (const CTxIn& txin, it->GetTx ().vin )
456
458
mapNextTx.erase (txin.prevout );
@@ -502,7 +504,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries &setDescendants
502
504
}
503
505
}
504
506
505
- void CTxMemPool::removeRecursive (const CTransaction &origTx)
507
+ void CTxMemPool::removeRecursive (const CTransaction &origTx, MemPoolRemovalReason reason )
506
508
{
507
509
// Remove transaction from memory pool
508
510
{
@@ -529,7 +531,8 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx)
529
531
BOOST_FOREACH (txiter it, txToRemove) {
530
532
CalculateDescendants (it, setAllRemoves);
531
533
}
532
- RemoveStaged (setAllRemoves, false );
534
+
535
+ RemoveStaged (setAllRemoves, false , reason);
533
536
}
534
537
}
535
538
@@ -567,7 +570,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
567
570
for (txiter it : txToRemove) {
568
571
CalculateDescendants (it, setAllRemoves);
569
572
}
570
- RemoveStaged (setAllRemoves, false );
573
+ RemoveStaged (setAllRemoves, false , MemPoolRemovalReason::REORG );
571
574
}
572
575
573
576
void CTxMemPool::removeConflicts (const CTransaction &tx)
@@ -581,7 +584,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx)
581
584
if (txConflict != tx)
582
585
{
583
586
ClearPrioritisation (txConflict.GetHash ());
584
- removeRecursive (txConflict);
587
+ removeRecursive (txConflict, MemPoolRemovalReason::CONFLICT );
585
588
}
586
589
}
587
590
}
@@ -610,7 +613,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
610
613
if (it != mapTx.end ()) {
611
614
setEntries stage;
612
615
stage.insert (it);
613
- RemoveStaged (stage, true );
616
+ RemoveStaged (stage, true , MemPoolRemovalReason::BLOCK );
614
617
}
615
618
removeConflicts (*tx);
616
619
ClearPrioritisation (tx->GetHash ());
@@ -989,11 +992,11 @@ size_t CTxMemPool::DynamicMemoryUsage() const {
989
992
return memusage::MallocUsage (sizeof (CTxMemPoolEntry) + 15 * sizeof (void *)) * mapTx.size () + memusage::DynamicUsage (mapNextTx) + memusage::DynamicUsage (mapDeltas) + memusage::DynamicUsage (mapLinks) + memusage::DynamicUsage (vTxHashes) + cachedInnerUsage;
990
993
}
991
994
992
- void CTxMemPool::RemoveStaged (setEntries &stage, bool updateDescendants) {
995
+ void CTxMemPool::RemoveStaged (setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason ) {
993
996
AssertLockHeld (cs);
994
997
UpdateForRemoveFromMempool (stage, updateDescendants);
995
998
BOOST_FOREACH (const txiter& it, stage) {
996
- removeUnchecked (it);
999
+ removeUnchecked (it, reason );
997
1000
}
998
1001
}
999
1002
@@ -1009,7 +1012,7 @@ int CTxMemPool::Expire(int64_t time) {
1009
1012
BOOST_FOREACH (txiter removeit, toremove) {
1010
1013
CalculateDescendants (removeit, stage);
1011
1014
}
1012
- RemoveStaged (stage, false );
1015
+ RemoveStaged (stage, false , MemPoolRemovalReason::EXPIRY );
1013
1016
return stage.size ();
1014
1017
}
1015
1018
@@ -1118,7 +1121,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
1118
1121
BOOST_FOREACH (txiter iter, stage)
1119
1122
txn.push_back (iter->GetTx ());
1120
1123
}
1121
- RemoveStaged (stage, false );
1124
+ RemoveStaged (stage, false , MemPoolRemovalReason::SIZELIMIT );
1122
1125
if (pvNoSpendsRemaining) {
1123
1126
BOOST_FOREACH (const CTransaction& tx, txn) {
1124
1127
BOOST_FOREACH (const CTxIn& txin, tx.vin ) {
0 commit comments