Bitcoin ABC 0.30.5
P2P Digital Currency
packages.h
Go to the documentation of this file.
1// Copyright (c) 2021 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
9#include <policy/policy.h>
11
12#include <vector>
13
15static constexpr uint32_t MAX_PACKAGE_COUNT{50};
17static constexpr uint32_t MAX_PACKAGE_SIZE{101};
18static_assert(MAX_PACKAGE_SIZE * 1000 >= MAX_STANDARD_TX_SIZE);
19
31 PCKG_TX,
34};
35
40using Package = std::vector<CTransactionRef>;
41
42class PackageValidationState : public ValidationState<PackageValidationResult> {
43};
44
53bool CheckPackage(const Package &txns, PackageValidationState &state);
54
62bool IsChildWithParents(const Package &package);
63
68bool IsChildWithParentsTree(const Package &package);
69
70/*
71 * Get the hash of these transactions' txids, concatenated in lexicographical
72 * order (treating the txids as little endian encoded uint256, smallest to
73 * largest).
74 *
75 * TODO Create a PackageHash class so we are type safe
76 */
77uint256 GetPackageHash(const Package &package);
78
79#endif // BITCOIN_POLICY_PACKAGES_H
Template for capturing information about block/transaction validation.
Definition: validation.h:89
256-bit opaque blob.
Definition: uint256.h:129
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:86
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition: packages.h:40
static constexpr uint32_t MAX_PACKAGE_COUNT
Default maximum number of transactions in a package.
Definition: packages.h:15
static constexpr uint32_t MAX_PACKAGE_SIZE
Default maximum total size of transactions in a package in KB.
Definition: packages.h:17
bool IsChildWithParentsTree(const Package &package)
Context-free check that a package IsChildWithParents() and none of the parents depend on each other (...
Definition: packages.cpp:109
bool CheckPackage(const Package &txns, PackageValidationState &state)
Context-free package policy checks:
Definition: packages.cpp:14
PackageValidationResult
A "reason" why a package was invalid.
Definition: packages.h:25
@ 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.
uint256 GetPackageHash(const Package &package)
Definition: packages.cpp:129
static constexpr unsigned int MAX_STANDARD_TX_SIZE
The maximum size for transactions we're willing to relay/mine.
Definition: policy.h:34