Skip to content

Commit b88d77a

Browse files
committed
[policy] Define packages
Define the Package type as an alias for a vector of transactions for now. Add PackageValidationResult, similar to TxValidationResult and BlockValidationResult for package-wide errors that cannot be reported within a single transaction result, such as having too many transactions in the package. We can update the concept of what a package is and have different logic for packages vs lists of transactions in the future, e.g. for package relay.
1 parent 249f43f commit b88d77a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ BITCOIN_CORE_H = \
193193
outputtype.h \
194194
policy/feerate.h \
195195
policy/fees.h \
196+
policy/packages.h \
196197
policy/policy.h \
197198
policy/rbf.h \
198199
policy/settings.h \

src/policy/packages.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
8+
#include <consensus/validation.h>
9+
#include <primitives/transaction.h>
10+
11+
#include <vector>
12+
13+
/** A "reason" why a package was invalid. It may be that one or more of the included
14+
* transactions is invalid or the package itself violates our rules.
15+
* We don't distinguish between consensus and policy violations right now.
16+
*/
17+
enum class PackageValidationResult {
18+
PCKG_RESULT_UNSET = 0, //!< Initial value. The package has not yet been rejected.
19+
PCKG_POLICY, //!< The package itself is invalid (e.g. too many transactions).
20+
PCKG_TX, //!< At least one tx is invalid.
21+
};
22+
23+
/** A package is an ordered list of transactions. The transactions cannot conflict with (spend the
24+
* same inputs as) one another. */
25+
using Package = std::vector<CTransactionRef>;
26+
27+
class PackageValidationState : public ValidationState<PackageValidationResult> {};
28+
29+
#endif // BITCOIN_POLICY_PACKAGES_H

0 commit comments

Comments
 (0)