aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglozow <gzhao408@berkeley.edu>2021-02-11 09:50:42 -0800
committerglozow <gzhao408@berkeley.edu>2021-05-20 21:34:31 +0100
commitb88d77aec5e7bef5305a668d15031351c0548b4d (patch)
treef579f8c5ab082d4e928bd1e5d793572b4125c1cd
parent249f43f3cc52b0ffdf2c47aad95ba9d195f6a45e (diff)
[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.
-rw-r--r--src/Makefile.am1
-rw-r--r--src/policy/packages.h29
2 files changed, 30 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 770bb76226..579cd4e919 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -193,6 +193,7 @@ BITCOIN_CORE_H = \
outputtype.h \
policy/feerate.h \
policy/fees.h \
+ policy/packages.h \
policy/policy.h \
policy/rbf.h \
policy/settings.h \
diff --git a/src/policy/packages.h b/src/policy/packages.h
new file mode 100644
index 0000000000..60aafb6d74
--- /dev/null
+++ b/src/policy/packages.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2021 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_POLICY_PACKAGES_H
+#define BITCOIN_POLICY_PACKAGES_H
+
+#include <consensus/validation.h>
+#include <primitives/transaction.h>
+
+#include <vector>
+
+/** 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.
+ */
+enum class PackageValidationResult {
+ PCKG_RESULT_UNSET = 0, //!< 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.
+};
+
+/** A package is an ordered list of transactions. The transactions cannot conflict with (spend the
+ * same inputs as) one another. */
+using Package = std::vector<CTransactionRef>;
+
+class PackageValidationState : public ValidationState<PackageValidationResult> {};
+
+#endif // BITCOIN_POLICY_PACKAGES_H