@@ -450,7 +450,36 @@ class MemPoolAccept
450450 /* * Whether we allow transactions to replace mempool transactions by BIP125 rules. If false,
451451 * any transaction spending the same inputs as a transaction in the mempool is considered
452452 * a conflict. */
453- const bool m_allow_bip125_replacement{true };
453+ const bool m_allow_bip125_replacement;
454+
455+ /* * Parameters for single transaction mempool validation. */
456+ static ATMPArgs SingleAccept (const CChainParams& chainparams, int64_t accept_time,
457+ bool bypass_limits, std::vector<COutPoint>& coins_to_uncache,
458+ bool test_accept) {
459+ return ATMPArgs{/* m_chainparams */ chainparams,
460+ /* m_accept_time */ accept_time,
461+ /* m_bypass_limits */ bypass_limits,
462+ /* m_coins_to_uncache */ coins_to_uncache,
463+ /* m_test_accept */ test_accept,
464+ /* m_allow_bip125_replacement */ true ,
465+ };
466+ }
467+
468+ /* * Parameters for test package mempool validation through testmempoolaccept. */
469+ static ATMPArgs PackageTestAccept (const CChainParams& chainparams, int64_t accept_time,
470+ std::vector<COutPoint>& coins_to_uncache) {
471+ return ATMPArgs{/* m_chainparams */ chainparams,
472+ /* m_accept_time */ accept_time,
473+ /* m_bypass_limits */ false ,
474+ /* m_coins_to_uncache */ coins_to_uncache,
475+ /* m_test_accept */ true ,
476+ /* m_allow_bip125_replacement */ false ,
477+ };
478+ }
479+
480+ // No default ctor to avoid exposing details to clients and allowing the possibility of
481+ // mixing up the order of the arguments. Use static functions above instead.
482+ ATMPArgs () = delete ;
454483 };
455484
456485 // Single transaction acceptance
@@ -1019,9 +1048,7 @@ static MempoolAcceptResult AcceptToMemoryPoolWithTime(const CChainParams& chainp
10191048 EXCLUSIVE_LOCKS_REQUIRED(cs_main)
10201049{
10211050 std::vector<COutPoint> coins_to_uncache;
1022- MemPoolAccept::ATMPArgs args { chainparams, nAcceptTime, bypass_limits, coins_to_uncache,
1023- test_accept, /* m_allow_bip125_replacement */ true };
1024-
1051+ auto args = MemPoolAccept::ATMPArgs::SingleAccept (chainparams, nAcceptTime, bypass_limits, coins_to_uncache, test_accept);
10251052 const MempoolAcceptResult result = MemPoolAccept (pool, active_chainstate).AcceptSingleTransaction (tx, args);
10261053 if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
10271054 // Remove coins that were not present in the coins cache before calling
@@ -1054,8 +1081,7 @@ PackageMempoolAcceptResult ProcessNewPackage(CChainState& active_chainstate, CTx
10541081
10551082 std::vector<COutPoint> coins_to_uncache;
10561083 const CChainParams& chainparams = Params ();
1057- MemPoolAccept::ATMPArgs args { chainparams, GetTime (), /* bypass_limits */ false , coins_to_uncache,
1058- test_accept, /* m_allow_bip125_replacement */ false };
1084+ auto args = MemPoolAccept::ATMPArgs::PackageTestAccept (chainparams, GetTime (), coins_to_uncache);
10591085 const PackageMempoolAcceptResult result = MemPoolAccept (pool, active_chainstate).AcceptMultipleTransactions (package, args);
10601086
10611087 // Uncache coins pertaining to transactions that were not submitted to the mempool.
0 commit comments