Bitcoin ABC 0.30.5
P2P Digital Currency
Classes | Typedefs | Enumerations | Functions | Variables
packages.h File Reference
#include <consensus/validation.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <vector>
Include dependency graph for packages.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  PackageValidationState
 

Typedefs

using Package = std::vector< CTransactionRef >
 A package is an ordered list of transactions. More...
 

Enumerations

enum class  PackageValidationResult { PCKG_RESULT_UNSET = 0 , PCKG_POLICY , PCKG_TX , PCKG_MEMPOOL_ERROR }
 A "reason" why a package was invalid. More...
 

Functions

bool CheckPackage (const Package &txns, PackageValidationState &state)
 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...
 
uint256 GetPackageHash (const Package &package)
 

Variables

static constexpr uint32_t MAX_PACKAGE_COUNT {50}
 Default maximum number of transactions in a package. More...
 
static constexpr uint32_t MAX_PACKAGE_SIZE {101}
 Default maximum total size of transactions in a package in KB. More...
 

Typedef Documentation

◆ Package

using Package = std::vector<CTransactionRef>

A package is an ordered list of transactions.

The transactions cannot conflict with (spend the same inputs as) one another.

Definition at line 40 of file packages.h.

Enumeration Type Documentation

◆ PackageValidationResult

enum class PackageValidationResult
strong

A "reason" why a package was invalid.

It may be that one or more of the included transactions is invalid or the package itself violates our rules. We don't distinguish between consensus and policy violations right now.

Enumerator
PCKG_RESULT_UNSET 

Initial value. The package has not yet been rejected.

PCKG_POLICY 

The package itself is invalid (e.g. too many transactions).

PCKG_TX 

At least one tx is invalid.

PCKG_MEMPOOL_ERROR 

Mempool logic error.

Definition at line 25 of file packages.h.

Function Documentation

◆ CheckPackage()

bool CheckPackage ( const Package txns,
PackageValidationState state 
)

Context-free package policy checks:

  1. The number of transactions cannot exceed MAX_PACKAGE_COUNT.
  2. The total virtual size cannot exceed MAX_PACKAGE_SIZE.
  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 14 of file packages.cpp.

Here is the call graph for this function:

◆ GetPackageHash()

uint256 GetPackageHash ( const Package package)

Definition at line 129 of file packages.cpp.

Here is the call graph for this function:

◆ 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 86 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 109 of file packages.cpp.

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

Variable Documentation

◆ MAX_PACKAGE_COUNT

constexpr uint32_t MAX_PACKAGE_COUNT {50}
staticconstexpr

Default maximum number of transactions in a package.

Definition at line 15 of file packages.h.

◆ MAX_PACKAGE_SIZE

constexpr uint32_t MAX_PACKAGE_SIZE {101}
staticconstexpr

Default maximum total size of transactions in a package in KB.

Definition at line 17 of file packages.h.