diff --git a/src/policy/packages.h b/src/policy/packages.h index c302178b2..e5bfc6150 100644 --- a/src/policy/packages.h +++ b/src/policy/packages.h @@ -1,36 +1,43 @@ // 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 +#include #include #include +/** Default maximum number of transactions in a package. */ +static constexpr uint32_t MAX_PACKAGE_COUNT{50}; +/** Default maximum total size of transactions in a package in KB. */ +static constexpr uint32_t MAX_PACKAGE_SIZE{101}; +static_assert(MAX_PACKAGE_SIZE * 1000 >= MAX_STANDARD_TX_SIZE); + /** * 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 { //! Initial value. The package has not yet been rejected. PCKG_RESULT_UNSET = 0, //! The package itself is invalid (e.g. too many transactions). PCKG_POLICY, //! At least one tx is invalid. PCKG_TX, }; /** * A package is an ordered list of transactions. The transactions cannot * conflict with (spend the same inputs as) one another. */ using Package = std::vector; class PackageValidationState : public ValidationState { }; #endif // BITCOIN_POLICY_PACKAGES_H diff --git a/src/test/txvalidation_tests.cpp b/src/test/txvalidation_tests.cpp index 80e452397..9ee524a2a 100644 --- a/src/test/txvalidation_tests.cpp +++ b/src/test/txvalidation_tests.cpp @@ -1,102 +1,175 @@ // Copyright (c) 2017-2019 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include +#include +#include #include #include