@@ -329,7 +329,7 @@ bool CheckSequenceLocks(const CTxMemPool& pool, const CTransaction& tx, int flag
329
329
// Returns the script flags which should be checked for a given block
330
330
static unsigned int GetBlockScriptFlags (const CBlockIndex* pindex, const Consensus::Params& chainparams);
331
331
332
- static void LimitMempoolSize (CTxMemPool& pool, size_t limit, std::chrono::seconds age)
332
+ static void LimitMempoolSize (CTxMemPool& pool, CCoinsViewCache& coins_cache, size_t limit, std::chrono::seconds age)
333
333
EXCLUSIVE_LOCKS_REQUIRED(pool.cs, ::cs_main)
334
334
{
335
335
int expired = pool.Expire (GetTime<std::chrono::seconds>() - age);
@@ -339,8 +339,9 @@ static void LimitMempoolSize(CTxMemPool& pool, size_t limit, std::chrono::second
339
339
340
340
std::vector<COutPoint> vNoSpendsRemaining;
341
341
pool.TrimToSize (limit, &vNoSpendsRemaining);
342
+ assert (std::addressof (::ChainstateActive ().CoinsTip ()) == std::addressof (coins_cache));
342
343
for (const COutPoint& removed : vNoSpendsRemaining)
343
- ::ChainstateActive ().CoinsTip() .Uncache(removed);
344
+ coins_cache .Uncache (removed);
344
345
}
345
346
346
347
static bool IsCurrentForFeeEstimation () EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@@ -403,7 +404,7 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
403
404
// We also need to remove any now-immature transactions
404
405
mempool.removeForReorg (&::ChainstateActive ().CoinsTip (), ::ChainActive ().Tip ()->nHeight + 1 , STANDARD_LOCKTIME_VERIFY_FLAGS);
405
406
// Re-limit mempool size, in case we added any transactions
406
- LimitMempoolSize (mempool, gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 , std::chrono::hours{gArgs .GetArg (" -mempoolexpiry" , DEFAULT_MEMPOOL_EXPIRY)});
407
+ LimitMempoolSize (mempool, :: ChainstateActive (). CoinsTip (), gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 , std::chrono::hours{gArgs .GetArg (" -mempoolexpiry" , DEFAULT_MEMPOOL_EXPIRY)});
407
408
}
408
409
409
410
/* *
@@ -1015,7 +1016,7 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
1015
1016
1016
1017
// trim mempool and check if tx was trimmed
1017
1018
if (!bypass_limits) {
1018
- LimitMempoolSize (m_pool, gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 , std::chrono::hours{gArgs .GetArg (" -mempoolexpiry" , DEFAULT_MEMPOOL_EXPIRY)});
1019
+ LimitMempoolSize (m_pool, :: ChainstateActive (). CoinsTip (), gArgs .GetArg (" -maxmempool" , DEFAULT_MAX_MEMPOOL_SIZE) * 1000000 , std::chrono::hours{gArgs .GetArg (" -mempoolexpiry" , DEFAULT_MEMPOOL_EXPIRY)});
1019
1020
if (!m_pool.exists (hash))
1020
1021
return state.Invalid (TxValidationResult::TX_MEMPOOL_POLICY, " mempool full" );
1021
1022
}
0 commit comments