@ -393,6 +393,7 @@ void CTxMemPool::AddTransactionsUpdated(unsigned int n)
bool CTxMemPool : : addUnchecked ( const uint256 & hash , const CTxMemPoolEntry & entry , setEntries & setAncestors , bool validFeeEstimate )
bool CTxMemPool : : addUnchecked ( const uint256 & hash , const CTxMemPoolEntry & entry , setEntries & setAncestors , bool validFeeEstimate )
{
{
NotifyEntryAdded ( entry . GetSharedTx ( ) ) ;
// Add to memory pool without checking anything.
// Add to memory pool without checking anything.
// Used by main.cpp AcceptToMemoryPool(), which DOES do
// Used by main.cpp AcceptToMemoryPool(), which DOES do
// all the appropriate checks.
// all the appropriate checks.
@ -449,8 +450,9 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
return true ;
return true ;
}
}
void CTxMemPool : : removeUnchecked ( txiter it )
void CTxMemPool : : removeUnchecked ( txiter it , MemPoolRemovalReason reason )
{
{
NotifyEntryRemoved ( it - > GetSharedTx ( ) , reason ) ;
const uint256 hash = it - > GetTx ( ) . GetHash ( ) ;
const uint256 hash = it - > GetTx ( ) . GetHash ( ) ;
BOOST_FOREACH ( const CTxIn & txin , it - > GetTx ( ) . vin )
BOOST_FOREACH ( const CTxIn & txin , it - > GetTx ( ) . vin )
mapNextTx . erase ( txin . prevout ) ;
mapNextTx . erase ( txin . prevout ) ;
@ -502,7 +504,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries &setDescendants
}
}
}
}
void CTxMemPool : : removeRecursive ( const CTransaction & origTx )
void CTxMemPool : : removeRecursive ( const CTransaction & origTx , MemPoolRemovalReason reason )
{
{
// Remove transaction from memory pool
// Remove transaction from memory pool
{
{
@ -529,7 +531,8 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx)
BOOST_FOREACH ( txiter it , txToRemove ) {
BOOST_FOREACH ( txiter it , txToRemove ) {
CalculateDescendants ( it , setAllRemoves ) ;
CalculateDescendants ( it , setAllRemoves ) ;
}
}
RemoveStaged ( setAllRemoves , false ) ;
RemoveStaged ( setAllRemoves , false , reason ) ;
}
}
}
}
@ -567,7 +570,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
for ( txiter it : txToRemove ) {
for ( txiter it : txToRemove ) {
CalculateDescendants ( it , setAllRemoves ) ;
CalculateDescendants ( it , setAllRemoves ) ;
}
}
RemoveStaged ( setAllRemoves , false ) ;
RemoveStaged ( setAllRemoves , false , MemPoolRemovalReason : : REORG ) ;
}
}
void CTxMemPool : : removeConflicts ( const CTransaction & tx )
void CTxMemPool : : removeConflicts ( const CTransaction & tx )
@ -581,7 +584,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx)
if ( txConflict ! = tx )
if ( txConflict ! = tx )
{
{
ClearPrioritisation ( txConflict . GetHash ( ) ) ;
ClearPrioritisation ( txConflict . GetHash ( ) ) ;
removeRecursive ( txConflict ) ;
removeRecursive ( txConflict , MemPoolRemovalReason : : CONFLICT ) ;
}
}
}
}
}
}
@ -610,7 +613,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
if ( it ! = mapTx . end ( ) ) {
if ( it ! = mapTx . end ( ) ) {
setEntries stage ;
setEntries stage ;
stage . insert ( it ) ;
stage . insert ( it ) ;
RemoveStaged ( stage , true ) ;
RemoveStaged ( stage , true , MemPoolRemovalReason : : BLOCK ) ;
}
}
removeConflicts ( * tx ) ;
removeConflicts ( * tx ) ;
ClearPrioritisation ( tx - > GetHash ( ) ) ;
ClearPrioritisation ( tx - > GetHash ( ) ) ;
@ -989,11 +992,11 @@ size_t CTxMemPool::DynamicMemoryUsage() const {
return memusage : : MallocUsage ( sizeof ( CTxMemPoolEntry ) + 15 * sizeof ( void * ) ) * mapTx . size ( ) + memusage : : DynamicUsage ( mapNextTx ) + memusage : : DynamicUsage ( mapDeltas ) + memusage : : DynamicUsage ( mapLinks ) + memusage : : DynamicUsage ( vTxHashes ) + 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 ) {
void CTxMemPool : : RemoveStaged ( setEntries & stage , bool updateDescendants , MemPoolRemovalReason reason ) {
AssertLockHeld ( cs ) ;
AssertLockHeld ( cs ) ;
UpdateForRemoveFromMempool ( stage , updateDescendants ) ;
UpdateForRemoveFromMempool ( stage , updateDescendants ) ;
BOOST_FOREACH ( const txiter & it , stage ) {
BOOST_FOREACH ( const txiter & it , stage ) {
removeUnchecked ( it ) ;
removeUnchecked ( it , reason ) ;
}
}
}
}
@ -1009,7 +1012,7 @@ int CTxMemPool::Expire(int64_t time) {
BOOST_FOREACH ( txiter removeit , toremove ) {
BOOST_FOREACH ( txiter removeit , toremove ) {
CalculateDescendants ( removeit , stage ) ;
CalculateDescendants ( removeit , stage ) ;
}
}
RemoveStaged ( stage , false ) ;
RemoveStaged ( stage , false , MemPoolRemovalReason : : EXPIRY ) ;
return stage . size ( ) ;
return stage . size ( ) ;
}
}
@ -1118,7 +1121,7 @@ void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRe
BOOST_FOREACH ( txiter iter , stage )
BOOST_FOREACH ( txiter iter , stage )
txn . push_back ( iter - > GetTx ( ) ) ;
txn . push_back ( iter - > GetTx ( ) ) ;
}
}
RemoveStaged ( stage , false ) ;
RemoveStaged ( stage , false , MemPoolRemovalReason : : SIZELIMIT ) ;
if ( pvNoSpendsRemaining ) {
if ( pvNoSpendsRemaining ) {
BOOST_FOREACH ( const CTransaction & tx , txn ) {
BOOST_FOREACH ( const CTransaction & tx , txn ) {
BOOST_FOREACH ( const CTxIn & txin , tx . vin ) {
BOOST_FOREACH ( const CTxIn & txin , tx . vin ) {