@@ -688,9 +688,7 @@ class MemPoolAccept
688688 bool ConsensusScriptChecks (const ATMPArgs& args, Workspace& ws) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs);
689689
690690 // Try to add the transaction to the mempool, removing any conflicts first.
691- // Returns true if the transaction is in the mempool after any size
692- // limiting is performed, false otherwise.
693- bool FinalizeSubpackage (const ATMPArgs& args, std::vector<Workspace>& ws) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs);
691+ void FinalizeSubpackage (const ATMPArgs& args, std::vector<Workspace>& ws) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs);
694692
695693 // Submit all transactions to the mempool and call ConsensusScriptChecks to add to the script
696694 // cache - should only be called after successful validation of all transactions in the package.
@@ -1285,14 +1283,12 @@ bool MemPoolAccept::ConsensusScriptChecks(const ATMPArgs& args, Workspace& ws)
12851283 return true ;
12861284}
12871285
1288- bool MemPoolAccept::FinalizeSubpackage (const ATMPArgs& args, std::vector<Workspace>& workspaces)
1286+ void MemPoolAccept::FinalizeSubpackage (const ATMPArgs& args, std::vector<Workspace>& workspaces)
12891287{
12901288 AssertLockHeld (cs_main);
12911289 AssertLockHeld (m_pool.cs );
12921290 const CTransaction& tx = *workspaces.front ().m_ptx ;
12931291 const uint256& hash = workspaces.front ().m_hash ;
1294- TxValidationState& state = workspaces.front ().m_state ;
1295- const bool bypass_limits = args.m_bypass_limits ;
12961292
12971293 if (!m_subpackage.m_all_conflicts .empty ()) Assume (args.m_allow_replacement );
12981294 // Remove conflicting transactions from the mempool
@@ -1323,18 +1319,6 @@ bool MemPoolAccept::FinalizeSubpackage(const ATMPArgs& args, std::vector<Workspa
13231319 // Don't attempt to process the same conflicts repeatedly during subpackage evaluation:
13241320 // they no longer exist on subsequent calls to Finalize() post-Apply()
13251321 m_subpackage.m_all_conflicts .clear ();
1326-
1327- // trim mempool and check if tx was trimmed
1328- // If we are validating a package, don't trim here because we could evict a previous transaction
1329- // in the package. LimitMempoolSize() should be called at the very end to make sure the mempool
1330- // is still within limits and package submission happens atomically.
1331- if (!args.m_package_submission && !bypass_limits) {
1332- LimitMempoolSize (m_pool, m_active_chainstate.CoinsTip ());
1333- if (!m_pool.exists (GenTxid::Txid (hash)))
1334- // The tx no longer meets our (new) mempool minimum feerate but could be reconsidered in a package.
1335- return state.Invalid (TxValidationResult::TX_RECONSIDERABLE, " mempool full" );
1336- }
1337- return true ;
13381322}
13391323
13401324bool MemPoolAccept::SubmitPackage (const ATMPArgs& args, std::vector<Workspace>& workspaces,
@@ -1467,11 +1451,19 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
14671451 ws.m_base_fees , effective_feerate, single_wtxid);
14681452 }
14691453
1470- if (!FinalizeSubpackage (args, workspaces)) {
1471- // The only possible failure reason is fee-related (mempool full).
1472- // Failed for fee reasons. Provide the effective feerate and which txns were included.
1473- Assume (ws.m_state .GetResult () == TxValidationResult::TX_RECONSIDERABLE);
1474- return MempoolAcceptResult::FeeFailure (ws.m_state , CFeeRate (ws.m_modified_fees , ws.m_vsize ), {ws.m_ptx ->GetWitnessHash ()});
1454+ FinalizeSubpackage (args, workspaces);
1455+
1456+ // trim mempool and check if tx was trimmed
1457+ // If we are validating a package, don't trim here because we could evict a previous transaction
1458+ // in the package. LimitMempoolSize() should be called at the very end to make sure the mempool
1459+ // is still within limits and package submission happens atomically.
1460+ if (!args.m_package_submission && !args.m_bypass_limits ) {
1461+ LimitMempoolSize (m_pool, m_active_chainstate.CoinsTip ());
1462+ if (!m_pool.exists (GenTxid::Txid (ws.m_hash ))) {
1463+ // The tx no longer meets our (new) mempool minimum feerate but could be reconsidered in a package.
1464+ ws.m_state .Invalid (TxValidationResult::TX_RECONSIDERABLE, " mempool full" );
1465+ return MempoolAcceptResult::FeeFailure (ws.m_state , CFeeRate (ws.m_modified_fees , ws.m_vsize ), {ws.m_ptx ->GetWitnessHash ()});
1466+ }
14751467 }
14761468
14771469 if (m_pool.m_opts .signals ) {
0 commit comments