| 471 | namespace { |
| 472 | |
| 473 | class MemPoolAccept |
| 474 | { |
| 475 | public: |
| 476 | explicit MemPoolAccept(CTxMemPool& mempool, CChainState& active_chainstate) : m_pool(mempool), m_view(&m_dummy), m_viewmempool(&active_chainstate.CoinsTip(), m_pool), m_active_chainstate(active_chainstate), |
| 477 | m_limit_ancestors(gArgs.GetIntArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT)), |
| 478 | m_limit_ancestor_size(gArgs.GetIntArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000), |
| 479 | m_limit_descendants(gArgs.GetIntArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT)), |
| 480 | m_limit_descendant_size(gArgs.GetIntArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)*1000) { |
| 481 | } |
| 482 | |
| 483 | // We put the arguments we're handed into a struct, so we can pass them |
| 484 | // around easier. |
| 485 | struct ATMPArgs { |
| 486 | const CChainParams& m_chainparams; |
| 487 | const int64_t m_accept_time; |
| 488 | const bool m_bypass_limits; |
| 489 | /* |
| 490 | * Return any outpoints which were not previously present in the coins |
| 491 | * cache, but were added as a result of validating the tx for mempool |
| 492 | * acceptance. This allows the caller to optionally remove the cache |
| 493 | * additions if the associated transaction ends up being rejected by |
| 494 | * the mempool. |
| 495 | */ |
| 496 | std::vector<COutPoint>& m_coins_to_uncache; |
| 497 | const bool m_test_accept; |
| 498 | /** Whether we allow transactions to replace mempool transactions by BIP125 rules. If false, |
| 499 | * any transaction spending the same inputs as a transaction in the mempool is considered |
| 500 | * a conflict. */ |
| 501 | const bool m_allow_bip125_replacement; |
| 502 | /** When true, the mempool will not be trimmed when individual transactions are submitted in |
| 503 | * Finalize(). Instead, limits should be enforced at the end to ensure the package is not |
| 504 | * partially submitted. |
| 505 | */ |
| 506 | const bool m_package_submission; |
| 507 | |
| 508 | /** Parameters for single transaction mempool validation. */ |
| 509 | static ATMPArgs SingleAccept(const CChainParams& chainparams, int64_t accept_time, |
| 510 | bool bypass_limits, std::vector<COutPoint>& coins_to_uncache, |
| 511 | bool test_accept) { |
| 512 | return ATMPArgs{/* m_chainparams */ chainparams, |
| 513 | /* m_accept_time */ accept_time, |
| 514 | /* m_bypass_limits */ bypass_limits, |
| 515 | /* m_coins_to_uncache */ coins_to_uncache, |
| 516 | /* m_test_accept */ test_accept, |
| 517 | /* m_allow_bip125_replacement */ true, |
| 518 | /* m_package_submission */ false, |
| 519 | }; |
| 520 | } |
| 521 | |
| 522 | /** Parameters for test package mempool validation through testmempoolaccept. */ |
| 523 | static ATMPArgs PackageTestAccept(const CChainParams& chainparams, int64_t accept_time, |
| 524 | std::vector<COutPoint>& coins_to_uncache) { |
| 525 | return ATMPArgs{/* m_chainparams */ chainparams, |
| 526 | /* m_accept_time */ accept_time, |
| 527 | /* m_bypass_limits */ false, |
| 528 | /* m_coins_to_uncache */ coins_to_uncache, |
| 529 | /* m_test_accept */ true, |
| 530 | /* m_allow_bip125_replacement */ false, |
no outgoing calls
no test coverage detected