Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
policy
packages.h
Go to the documentation of this file.
1
// Copyright (c) 2021-present 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
#include <
util/hasher.h
>
13
14
#include <cstdint>
15
#include <unordered_set>
16
#include <vector>
17
19
static
constexpr
uint32_t
MAX_PACKAGE_COUNT
{25};
24
static
constexpr
uint32_t
MAX_PACKAGE_WEIGHT
= 404'000;
25
static_assert
(
MAX_PACKAGE_WEIGHT
>= MAX_STANDARD_TX_WEIGHT);
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.
29
static_assert
(DEFAULT_CLUSTER_LIMIT >=
MAX_PACKAGE_COUNT
);
30
static_assert
(
MAX_PACKAGE_WEIGHT
<= DEFAULT_CLUSTER_SIZE_LIMIT_KVB * WITNESS_SCALE_FACTOR * 1000);
31
36
enum class
PackageValidationResult
{
37
PCKG_RESULT_UNSET
= 0,
38
PCKG_POLICY
,
39
PCKG_TX
,
40
PCKG_MEMPOOL_ERROR
,
41
};
42
45
using
Package
= std::vector<CTransactionRef>;
46
47
class
PackageValidationState
:
public
ValidationState
<PackageValidationResult> {};
48
55
bool
IsTopoSortedPackage
(
const
Package
& txns);
56
66
bool
IsConsistentPackage
(
const
Package
& txns);
67
74
bool
IsWellFormedPackage
(
const
Package
& txns,
PackageValidationState
& state);
75
80
bool
IsChildWithParents
(
const
Package
& package);
81
85
bool
IsChildWithParentsTree
(
const
Package
& package);
86
90
uint256
GetPackageHash
(
const
std::vector<CTransactionRef>& transactions);
91
92
#endif
// BITCOIN_POLICY_PACKAGES_H
PackageValidationState
Definition
packages.h:47
ValidationState
Template for capturing information about block/transaction validation.
Definition
validation.h:76
uint256
256-bit opaque blob.
Definition
uint256.h:195
validation.h
consensus.h
hasher.h
IsChildWithParents
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
IsWellFormedPackage
bool IsWellFormedPackage(const Package &txns, PackageValidationState &state)
Context-free package policy checks:
Definition
packages.cpp:79
IsConsistentPackage
bool IsConsistentPackage(const Package &txns)
Checks that these transactions don't conflict, i.e., spend the same prevout.
Definition
packages.cpp:52
IsChildWithParentsTree
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
IsTopoSortedPackage
bool IsTopoSortedPackage(const Package &txns, std::unordered_set< Txid, SaltedTxidHasher > &later_txids)
IsTopoSortedPackage where a set of txids has been pre-populated.
Definition
packages.cpp:19
GetPackageHash
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
Package
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition
packages.h:45
MAX_PACKAGE_WEIGHT
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
MAX_PACKAGE_COUNT
static constexpr uint32_t MAX_PACKAGE_COUNT
Default maximum number of transactions in a package.
Definition
packages.h:19
PackageValidationResult
PackageValidationResult
A "reason" why a package was invalid.
Definition
packages.h:36
PackageValidationResult::PCKG_POLICY
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
Definition
packages.h:38
PackageValidationResult::PCKG_RESULT_UNSET
@ PCKG_RESULT_UNSET
Initial value. The package has not yet been rejected.
Definition
packages.h:37
PackageValidationResult::PCKG_MEMPOOL_ERROR
@ PCKG_MEMPOOL_ERROR
Mempool logic error.
Definition
packages.h:40
PackageValidationResult::PCKG_TX
@ PCKG_TX
At least one tx is invalid.
Definition
packages.h:39
policy.h
transaction.h
Generated on
for Bitcoin Core by
1.18.0