12#include <unordered_set>
21 "package-too-many-transactions");
26 return sum + GetVirtualTransactionSize(*tx);
40 std::unordered_set<TxId, SaltedTxIdHasher>
later_txids;
41 std::transform(
txns.cbegin(),
txns.cend(),
43 [](
const auto &tx) { return tx->GetId(); });
49 "package-contains-duplicates");
52 for (
const auto &tx :
txns) {
53 for (
const auto &input : tx->vin) {
58 "package-not-sorted");
66 std::unordered_set<COutPoint, SaltedOutpointHasher>
inputs_seen;
67 for (
const auto &tx :
txns) {
68 for (
const auto &input : tx->vin) {
72 "conflict-in-package");
79 std::transform(tx->vin.cbegin(), tx->vin.cend(),
81 [](
const auto &input) { return input.prevout; });
88 [](
const auto &tx) { return tx != nullptr; }));
96 std::unordered_set<TxId, SaltedTxIdHasher>
input_txids;
97 std::transform(
child->vin.cbegin(),
child->vin.cend(),
99 [](
const auto &input) { return input.prevout.GetTxId(); });
105 return input_txids.count(ptx->GetId()) > 0;
113 std::unordered_set<TxId, SaltedTxIdHasher>
parent_txids;
116 [](
const auto &
ptx) { return ptx->GetId(); });
120 for (const auto &input : ptx->vin) {
121 if (parent_txids.count(input.prevout.GetTxId()) > 0) {
134 [](
const auto &tx) { return tx->GetId(); });
138 [](
const auto &
lhs,
const auto &
rhs) { return lhs < rhs; });
A writer stream (for serialization) that computes a 256-bit hash.
uint256 GetSHA256()
Compute the SHA256 hash of all data written to this object.
bool Invalid(Result result, const std::string &reject_reason="", const std::string &debug_message="")
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...
bool IsChildWithParentsTree(const Package &package)
Context-free check that a package IsChildWithParents() and none of the parents depend on each other (...
bool CheckPackage(const Package &txns, PackageValidationState &state)
Context-free package policy checks:
uint256 GetPackageHash(const Package &package)
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
static constexpr uint32_t MAX_PACKAGE_COUNT
Default maximum number of transactions in a package.
static constexpr uint32_t MAX_PACKAGE_SIZE
Default maximum total size of transactions in a package in KB.
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...