mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
[refactor] move package checks into helper functions
This allows IsSorted() and IsConsistent() to be used by themselves. IsSorted() with a precomputed set is used so that we don't create this set multiple times.
This commit is contained in:
@@ -1258,7 +1258,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
|
||||
|
||||
// These context-free package limits can be done before taking the mempool lock.
|
||||
PackageValidationState package_state;
|
||||
if (!CheckPackage(txns, package_state)) return PackageMempoolAcceptResult(package_state, {});
|
||||
if (!CheckPackage(txns, package_state, /*require_sorted=*/true)) return PackageMempoolAcceptResult(package_state, {});
|
||||
|
||||
std::vector<Workspace> workspaces{};
|
||||
workspaces.reserve(txns.size());
|
||||
@@ -1405,7 +1405,9 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptPackage(const Package& package,
|
||||
// transactions and thus won't return any MempoolAcceptResults, just a package-wide error.
|
||||
|
||||
// Context-free package checks.
|
||||
if (!CheckPackage(package, package_state_quit_early)) return PackageMempoolAcceptResult(package_state_quit_early, {});
|
||||
if (!CheckPackage(package, package_state_quit_early, /*require_sorted=*/true)) {
|
||||
return PackageMempoolAcceptResult(package_state_quit_early, {});
|
||||
}
|
||||
|
||||
// All transactions in the package must be a parent of the last transaction. This is just an
|
||||
// opportunity for us to fail fast on a context-free check without taking the mempool lock.
|
||||
|
||||
Reference in New Issue
Block a user