Bitcoin Core  27.99.0
P2P Digital Currency
Functions
packages.cpp File Reference
#include <policy/packages.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <uint256.h>
#include <util/check.h>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <memory>
#include <numeric>
Include dependency graph for packages.cpp:

Go to the source code of this file.

Functions

bool IsTopoSortedPackage (const Package &txns, std::unordered_set< uint256, SaltedTxidHasher > &later_txids)
 IsTopoSortedPackage where a set of txids has been pre-populated. More...
 
bool IsTopoSortedPackage (const Package &txns)
 If any direct dependencies exist between transactions (i.e. More...
 
bool IsConsistentPackage (const Package &txns)
 Checks that these transactions don't conflict, i.e., spend the same prevout. More...
 
bool IsWellFormedPackage (const Package &txns, PackageValidationState &state, bool require_sorted)
 Context-free package policy checks: More...
 
bool IsChildWithParents (const Package &package)
 Context-free check that a package is exactly one child and its parents; not all parents need to be present, but the package must not contain any transactions that are not the child's parents. More...
 
bool IsChildWithParentsTree (const Package &package)
 Context-free check that a package IsChildWithParents() and none of the parents depend on each other (the package is a "tree"). More...
 

Function Documentation

◆ 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 present, but the package must not contain any transactions that are not the child's parents.

It is expected to be sorted, which means the last transaction must be the child.

Definition at line 119 of file packages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsChildWithParentsTree()

bool IsChildWithParentsTree ( const Package package)

Context-free check that a package IsChildWithParents() and none of the parents depend on each other (the package is a "tree").

Definition at line 136 of file packages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsConsistentPackage()

bool IsConsistentPackage ( const Package txns)

Checks that these transactions don't conflict, i.e., spend the same prevout.

This includes checking that there are no duplicate transactions. Since these checks require looking at the inputs of a transaction, returns false immediately if any transactions have empty vin.

Does not check consistency of a transaction with oneself; does not check if a transaction spends the same prevout multiple times (see bad-txns-inputs-duplicate in CheckTransaction()).

Returns
true if there are no conflicts. False if any two transactions spend the same prevout.

Definition at line 52 of file packages.cpp.

Here is the caller graph for this function:

◆ IsTopoSortedPackage() [1/2]

bool IsTopoSortedPackage ( const Package txns)

If any direct dependencies exist between transactions (i.e.

a child spending the output of a parent), checks that all parents appear somewhere in the list before their respective children. No other ordering is enforced. This function cannot detect indirect dependencies (e.g. a transaction's grandparent if its parent is not present).

Returns
true if sorted. False if any tx spends the output of a tx that appears later in txns.

Definition at line 43 of file packages.cpp.

Here is the call graph for this function:

◆ IsTopoSortedPackage() [2/2]

bool IsTopoSortedPackage ( const Package txns,
std::unordered_set< uint256, SaltedTxidHasher > &  later_txids 
)

IsTopoSortedPackage where a set of txids has been pre-populated.

The set is assumed to be correct and is mutated within this function (even if return value is false).

Definition at line 19 of file packages.cpp.

Here is the caller graph for this function:

◆ IsWellFormedPackage()

bool IsWellFormedPackage ( const Package txns,
PackageValidationState state,
bool  require_sorted 
)

Context-free package policy checks:

  1. The number of transactions cannot exceed MAX_PACKAGE_COUNT.
  2. The total weight cannot exceed MAX_PACKAGE_WEIGHT.
  3. If any dependencies exist between transactions, parents must appear before children.
  4. Transactions cannot conflict, i.e., spend the same inputs.

Definition at line 79 of file packages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: