Bitcoin Core 30.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
10#include <policy/policy.h>
12#include <util/hasher.h>
13
14#include <cstdint>
15#include <unordered_set>
16#include <vector>
17
19static constexpr uint32_t MAX_PACKAGE_COUNT{25};
24static constexpr uint32_t MAX_PACKAGE_WEIGHT = 404'000;
26
27// Packages are part of a single cluster, so ensure that the package limits are
28// set within the mempool's cluster size limits.
31
39 PCKG_TX,
41};
42
45using Package = std::vector<CTransactionRef>;
46
47class PackageValidationState : public ValidationState<PackageValidationResult> {};
48
55bool IsTopoSortedPackage(const Package& txns);
56
66bool IsConsistentPackage(const Package& txns);
67
74bool IsWellFormedPackage(const Package& txns, PackageValidationState& state, bool require_sorted);
75
80bool IsChildWithParents(const Package& package);
81
85bool IsChildWithParentsTree(const Package& package);
86
90uint256 GetPackageHash(const std::vector<CTransactionRef>& transactions);
91
92#endif // BITCOIN_POLICY_PACKAGES_H
Template for capturing information about block/transaction validation.
Definition: validation.h:76
256-bit opaque blob.
Definition: uint256.h:195
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:119
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition: packages.h:45
static constexpr uint32_t MAX_PACKAGE_WEIGHT
Default maximum total weight of transactions in a package in weight to allow for context-less checks.
Definition: packages.h:24
bool IsConsistentPackage(const Package &txns)
Checks that these transactions don't conflict, i.e., spend the same prevout.
Definition: packages.cpp:52
static constexpr uint32_t MAX_PACKAGE_COUNT
Default maximum number of transactions in a package.
Definition: packages.h:19
bool IsWellFormedPackage(const Package &txns, PackageValidationState &state, bool require_sorted)
Context-free package policy checks:
Definition: packages.cpp:79
bool IsChildWithParentsTree(const Package &package)
Context-free check that a package IsChildWithParents() and none of the parents depend on each other (...
Definition: packages.cpp:136
uint256 GetPackageHash(const std::vector< CTransactionRef > &transactions)
Get the hash of the concatenated wtxids of transactions, with wtxids treated as a little-endian numbe...
Definition: packages.cpp:151
PackageValidationResult
A "reason" why a package was invalid.
Definition: packages.h:36
@ 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.
bool IsTopoSortedPackage(const Package &txns)
If any direct dependencies exist between transactions (i.e.
Definition: packages.cpp:43
static constexpr unsigned int DEFAULT_CLUSTER_SIZE_LIMIT_KVB
Maximum size of cluster in virtual kilobytes.
Definition: policy.h:71
static constexpr int32_t MAX_STANDARD_TX_WEIGHT
The maximum weight for transactions we're willing to relay/mine.
Definition: policy.h:35
static constexpr unsigned int DEFAULT_CLUSTER_LIMIT
Maximum number of transactions per cluster (default)
Definition: policy.h:69