Bitcoin Core  24.99.0
P2P Digital Currency
packages.h
Go to the documentation of this file.
1 // Copyright (c) 2021-2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_POLICY_PACKAGES_H
6 #define BITCOIN_POLICY_PACKAGES_H
7 
8 #include <consensus/consensus.h>
9 #include <consensus/validation.h>
10 #include <policy/policy.h>
11 #include <primitives/transaction.h>
12 
13 #include <cstdint>
14 #include <vector>
15 
17 static constexpr uint32_t MAX_PACKAGE_COUNT{25};
19 static constexpr uint32_t MAX_PACKAGE_SIZE{101};
21 
22 // If a package is submitted, it must be within the mempool's ancestor/descendant limits. Since a
23 // submitted package must be child-with-unconfirmed-parents (all of the transactions are an ancestor
24 // of the child), package limits are ultimately bounded by mempool package limits. Ensure that the
25 // defaults reflect this constraint.
30 
36  PCKG_RESULT_UNSET = 0,
37  PCKG_POLICY,
38  PCKG_TX,
40 };
41 
44 using Package = std::vector<CTransactionRef>;
45 
46 class PackageValidationState : public ValidationState<PackageValidationResult> {};
47 
54 bool CheckPackage(const Package& txns, PackageValidationState& state);
55 
60 bool IsChildWithParents(const Package& package);
61 
62 #endif // BITCOIN_POLICY_PACKAGES_H
Template for capturing information about block/transaction validation.
Definition: validation.h:92
static const int WITNESS_SCALE_FACTOR
Definition: consensus.h:21
bool IsChildWithParents(const Package &package)
Context-free check that a package is exactly one child and its parents; not all parents need to be pr...
Definition: packages.cpp:68
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition: packages.h:44
static constexpr uint32_t MAX_PACKAGE_COUNT
Default maximum number of transactions in a package.
Definition: packages.h:17
static constexpr uint32_t MAX_PACKAGE_SIZE
Default maximum total virtual size of transactions in a package in KvB.
Definition: packages.h:19
bool CheckPackage(const Package &txns, PackageValidationState &state)
Context-free package policy checks:
Definition: packages.cpp:18
PackageValidationResult
A "reason" why a package was invalid.
Definition: packages.h:35
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
@ PCKG_RESULT_UNSET
Initial value. The package has not yet been rejected.
@ PCKG_MEMPOOL_ERROR
Mempool logic error.
@ PCKG_TX
At least one tx is invalid.
static constexpr unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT_KVB
Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors.
Definition: policy.h:61
static constexpr unsigned int DEFAULT_DESCENDANT_LIMIT
Default for -limitdescendantcount, max number of in-mempool descendants.
Definition: policy.h:63
static constexpr unsigned int MAX_STANDARD_TX_WEIGHT
The maximum weight for transactions we're willing to relay/mine.
Definition: policy.h:27
static constexpr unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT_KVB
Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants.
Definition: policy.h:65
static constexpr unsigned int DEFAULT_ANCESTOR_LIMIT
Default for -limitancestorcount, max number of in-mempool ancestors.
Definition: policy.h:59