Branch data Line data Source code
1 : : // Copyright (c) 2022 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 : : #ifndef BITCOIN_KERNEL_MEMPOOL_LIMITS_H 5 : : #define BITCOIN_KERNEL_MEMPOOL_LIMITS_H 6 : : 7 : : #include <policy/policy.h> 8 : : 9 : : #include <cstdint> 10 : : 11 : : namespace kernel { 12 : : /** 13 : : * Options struct containing limit options for a CTxMemPool. Default constructor 14 : : * populates the struct with sane default values which can be modified. 15 : : * 16 : : * Most of the time, this struct should be referenced as CTxMemPool::Limits. 17 : : */ 18 : : struct MemPoolLimits { 19 : : //! The maximum allowed number of transactions in a package including the entry and its ancestors. 20 : : int64_t ancestor_count{DEFAULT_ANCESTOR_LIMIT}; 21 : : //! The maximum allowed size in virtual bytes of an entry and its ancestors within a package. 22 : : int64_t ancestor_size_vbytes{DEFAULT_ANCESTOR_SIZE_LIMIT_KVB * 1'000}; 23 : : //! The maximum allowed number of transactions in a package including the entry and its descendants. 24 : : int64_t descendant_count{DEFAULT_DESCENDANT_LIMIT}; 25 : : //! The maximum allowed size in virtual bytes of an entry and its descendants within a package. 26 : : int64_t descendant_size_vbytes{DEFAULT_DESCENDANT_SIZE_LIMIT_KVB * 1'000}; 27 : : 28 : : /** 29 : : * @return MemPoolLimits with all the limits set to the maximum 30 : : */ 31 : 7510 : static constexpr MemPoolLimits NoLimits() 32 : : { 33 : 7510 : int64_t no_limit{std::numeric_limits<int64_t>::max()}; 34 : 7510 : return {no_limit, no_limit, no_limit, no_limit}; 35 : : } 36 : : }; 37 : : } // namespace kernel 38 : : 39 : : #endif // BITCOIN_KERNEL_MEMPOOL_LIMITS_H