Bitcoin Core  26.99.0
P2P Digital Currency
Classes | Functions
v3_policy.cpp File Reference
#include <policy/v3_policy.h>
#include <coins.h>
#include <consensus/amount.h>
#include <logging.h>
#include <tinyformat.h>
#include <util/check.h>
#include <algorithm>
#include <numeric>
#include <vector>
Include dependency graph for v3_policy.cpp:

Go to the source code of this file.

Classes

struct  ParentInfo
 Helper for PackageV3Checks, storing info for a mempool or package parent. More...
 

Functions

std::vector< size_t > FindInPackageParents (const Package &package, const CTransactionRef &ptx)
 Helper for PackageV3Checks: Returns a vector containing the indices of transactions (within package) that are direct parents of ptx. More...
 
std::optional< std::string > PackageV3Checks (const CTransactionRef &ptx, int64_t vsize, const Package &package, const CTxMemPool::setEntries &mempool_ancestors)
 Must be called for every transaction that is submitted within a package, even if not v3. More...
 
std::optional< std::string > SingleV3Checks (const CTransactionRef &ptx, const CTxMemPool::setEntries &mempool_ancestors, const std::set< Txid > &direct_conflicts, int64_t vsize)
 Must be called for every transaction, even if not v3. More...
 

Function Documentation

◆ FindInPackageParents()

std::vector<size_t> FindInPackageParents ( const Package package,
const CTransactionRef ptx 
)

Helper for PackageV3Checks: Returns a vector containing the indices of transactions (within package) that are direct parents of ptx.

Definition at line 19 of file v3_policy.cpp.

Here is the caller graph for this function:

◆ PackageV3Checks()

std::optional<std::string> PackageV3Checks ( const CTransactionRef ptx,
int64_t  vsize,
const Package package,
const CTxMemPool::setEntries mempool_ancestors 
)

Must be called for every transaction that is submitted within a package, even if not v3.

For each transaction in a package: If it's not a v3 transaction, verify it has no direct v3 parents in the mempool or the package.

If it is a v3 transaction, verify that any direct parents in the mempool or the package are v3. If such a parent exists, verify that parent has no other children in the package or the mempool, and that the transaction itself has no children in the package.

If any v3 violations in the package exist, this test will fail for one of them:

  • if a v3 transaction T has a parent in the mempool and a child in the package, then PV3C(T) will fail
  • if a v3 transaction T has a parent in the package and a child in the package, then PV3C(T) will fail
  • if a v3 transaction T and a v3 (sibling) transaction U have some parent in the mempool, then PV3C(T) and PV3C(U) will fail
  • if a v3 transaction T and a v3 (sibling) transaction U have some parent in the package, then PV3C(T) and PV3C(U) will fail
  • if a v3 transaction T has a parent P and a grandparent G in the package, then PV3C(P) will fail (though PV3C(G) and PV3C(T) might succeed).
Returns
debug string if an error occurs, std::nullopt otherwise.

Definition at line 58 of file v3_policy.cpp.

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

◆ SingleV3Checks()

std::optional<std::string> SingleV3Checks ( const CTransactionRef ptx,
const CTxMemPool::setEntries mempool_ancestors,
const std::set< Txid > &  direct_conflicts,
int64_t  vsize 
)

Must be called for every transaction, even if not v3.

Not strictly necessary for transactions accepted through AcceptMultipleTransactions.

Checks the following rules:

  1. A v3 tx must only have v3 unconfirmed ancestors.
  2. A non-v3 tx must only have non-v3 unconfirmed ancestors.
  3. A v3's ancestor set, including itself, must be within V3_ANCESTOR_LIMIT.
  4. A v3's descendant set, including itself, must be within V3_DESCENDANT_LIMIT.
  5. If a v3 tx has any unconfirmed ancestors, the tx's sigop-adjusted vsize must be within V3_CHILD_MAX_VSIZE.
Parameters
[in]mempool_ancestorsThe in-mempool ancestors of ptx.
[in]direct_conflictsIn-mempool transactions this tx conflicts with. These conflicts are used to more accurately calculate the resulting descendant count of in-mempool ancestors.
[in]vsizeThe sigop-adjusted virtual size of ptx.
Returns
debug string if an error occurs, std::nullopt otherwise.

Definition at line 161 of file v3_policy.cpp.

Here is the caller graph for this function: