@@ -1273,19 +1273,20 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
1273
1273
PackageMempoolAcceptResult MemPoolAccept::AcceptPackage (const Package& package, ATMPArgs& args)
1274
1274
{
1275
1275
AssertLockHeld (cs_main);
1276
- PackageValidationState package_state;
1276
+ // Used if returning a PackageMempoolAcceptResult directly from this function.
1277
+ PackageValidationState package_state_quit_early;
1277
1278
1278
1279
// Check that the package is well-formed. If it isn't, we won't try to validate any of the
1279
1280
// transactions and thus won't return any MempoolAcceptResults, just a package-wide error.
1280
1281
1281
1282
// Context-free package checks.
1282
- if (!CheckPackage (package, package_state )) return PackageMempoolAcceptResult (package_state , {});
1283
+ if (!CheckPackage (package, package_state_quit_early )) return PackageMempoolAcceptResult (package_state_quit_early , {});
1283
1284
1284
1285
// All transactions in the package must be a parent of the last transaction. This is just an
1285
1286
// opportunity for us to fail fast on a context-free check without taking the mempool lock.
1286
1287
if (!IsChildWithParents (package)) {
1287
- package_state .Invalid (PackageValidationResult::PCKG_POLICY, " package-not-child-with-parents" );
1288
- return PackageMempoolAcceptResult (package_state , {});
1288
+ package_state_quit_early .Invalid (PackageValidationResult::PCKG_POLICY, " package-not-child-with-parents" );
1289
+ return PackageMempoolAcceptResult (package_state_quit_early , {});
1289
1290
}
1290
1291
1291
1292
// IsChildWithParents() guarantees the package is > 1 transactions.
@@ -1317,8 +1318,8 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package,
1317
1318
return unconfirmed_parent_txids.count (input.prevout .hash ) > 0 || m_view.HaveCoin (input.prevout );
1318
1319
};
1319
1320
if (!std::all_of (child->vin .cbegin (), child->vin .cend (), package_or_confirmed)) {
1320
- package_state .Invalid (PackageValidationResult::PCKG_POLICY, " package-not-child-with-unconfirmed-parents" );
1321
- return PackageMempoolAcceptResult (package_state , {});
1321
+ package_state_quit_early .Invalid (PackageValidationResult::PCKG_POLICY, " package-not-child-with-unconfirmed-parents" );
1322
+ return PackageMempoolAcceptResult (package_state_quit_early , {});
1322
1323
}
1323
1324
// Protect against bugs where we pull more inputs from disk that miss being added to
1324
1325
// coins_to_uncache. The backend will be connected again when needed in PreChecks.
@@ -1381,6 +1382,8 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package,
1381
1382
// future. Continue individually validating the rest of the transactions, because
1382
1383
// some of them may still be valid.
1383
1384
quit_early = true ;
1385
+ package_state_quit_early.Invalid (PackageValidationResult::PCKG_TX, " transaction failed" );
1386
+ results.emplace (wtxid, single_res);
1384
1387
} else {
1385
1388
txns_new.push_back (tx);
1386
1389
}
@@ -1390,7 +1393,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package,
1390
1393
// Nothing to do if the entire package has already been submitted.
1391
1394
if (quit_early || txns_new.empty ()) {
1392
1395
// No package feerate when no package validation was done.
1393
- return PackageMempoolAcceptResult (package_state , std::move (results));
1396
+ return PackageMempoolAcceptResult (package_state_quit_early , std::move (results));
1394
1397
}
1395
1398
// Validate the (deduplicated) transactions as a package.
1396
1399
auto submission_result = AcceptMultipleTransactions (txns_new, args);
0 commit comments