@@ -450,7 +450,36 @@ class MemPoolAccept
450
450
/* * Whether we allow transactions to replace mempool transactions by BIP125 rules. If false,
451
451
* any transaction spending the same inputs as a transaction in the mempool is considered
452
452
* 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 ;
454
483
};
455
484
456
485
// Single transaction acceptance
@@ -1019,9 +1048,7 @@ static MempoolAcceptResult AcceptToMemoryPoolWithTime(const CChainParams& chainp
1019
1048
EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1020
1049
{
1021
1050
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);
1025
1052
const MempoolAcceptResult result = MemPoolAccept (pool, active_chainstate).AcceptSingleTransaction (tx, args);
1026
1053
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
1027
1054
// Remove coins that were not present in the coins cache before calling
@@ -1054,8 +1081,7 @@ PackageMempoolAcceptResult ProcessNewPackage(CChainState& active_chainstate, CTx
1054
1081
1055
1082
std::vector<COutPoint> coins_to_uncache;
1056
1083
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);
1059
1085
const PackageMempoolAcceptResult result = MemPoolAccept (pool, active_chainstate).AcceptMultipleTransactions (package, args);
1060
1086
1061
1087
// Uncache coins pertaining to transactions that were not submitted to the mempool.
0 commit comments