Skip to content

Commit 3cd663a

Browse files
committed
[policy] ancestor/descendant limits for packages
1 parent c6e016a commit 3cd663a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/validation.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,19 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
10791079
m_viewmempool.PackageAddTransaction(ws.m_ptx);
10801080
}
10811081

1082+
// Apply package mempool ancestor/descendant limits. Skip if there is only one transaction,
1083+
// because it's unnecessary. Also, CPFP carve out can increase the limit for individual
1084+
// transactions, but this exemption is not extended to packages in CheckPackageLimits().
1085+
std::string err_string;
1086+
if (txns.size() > 1 &&
1087+
!m_pool.CheckPackageLimits(txns, m_limit_ancestors, m_limit_ancestor_size, m_limit_descendants,
1088+
m_limit_descendant_size, err_string)) {
1089+
// All transactions must have individually passed mempool ancestor and descendant limits
1090+
// inside of PreChecks(), so this is separate from an individual transaction error.
1091+
package_state.Invalid(PackageValidationResult::PCKG_POLICY, "package-mempool-limits", err_string);
1092+
return PackageMempoolAcceptResult(package_state, std::move(results));
1093+
}
1094+
10821095
for (Workspace& ws : workspaces) {
10831096
PrecomputedTransactionData txdata;
10841097
if (!PolicyScriptChecks(args, ws, txdata)) {

0 commit comments

Comments
 (0)