From b85af25f8770974bae4ef3fae64e75ef6dd2d3c2 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Thu, 15 Sep 2022 18:26:21 +0100 Subject: [PATCH] refactor: mempool: add MemPoolLimits::NoLimits() There are quite a few places in the codebase that require us to construct a CTxMemPool without limits on ancestors and descendants. This helper function allows us to get rid of all that duplication. --- src/kernel/mempool_limits.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/kernel/mempool_limits.h b/src/kernel/mempool_limits.h index e192e7e6cd..8d4495c3cb 100644 --- a/src/kernel/mempool_limits.h +++ b/src/kernel/mempool_limits.h @@ -24,6 +24,15 @@ struct MemPoolLimits { int64_t descendant_count{DEFAULT_DESCENDANT_LIMIT}; //! The maximum allowed size in virtual bytes of an entry and its descendants within a package. int64_t descendant_size_vbytes{DEFAULT_DESCENDANT_SIZE_LIMIT_KVB * 1'000}; + + /** + * @return MemPoolLimits with all the limits set to the maximum + */ + static constexpr MemPoolLimits NoLimits() + { + int64_t no_limit{std::numeric_limits::max()}; + return {no_limit, no_limit, no_limit, no_limit}; + } }; } // namespace kernel