From 82f00de7a6a60cbc9ad0c6e1d0ffb1bc70c49af5 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Thu, 28 Oct 2021 13:46:19 -0400 Subject: mempool: Pass in -maxmempool instead of referencing gArgs - Store the mempool size limit (-maxmempool) in CTxMemPool as a member. - Remove the requirement to explicitly specify a mempool size limit for CTxMemPool::GetMinFee(...) and LimitMempoolSize(...), just use the stored mempool size limit where possible. - Remove all now-unnecessary instances of: gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE_MB) * 1000000 The code change in CChainState::GetCoinsCacheSizeState() is correct since the coinscache should not repurpose "extra" mempool memory headroom for itself if the mempool doesn't even exist. --- src/kernel/mempool_options.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/kernel/mempool_options.h') diff --git a/src/kernel/mempool_options.h b/src/kernel/mempool_options.h index c3d54bf0f4..e8c129050e 100644 --- a/src/kernel/mempool_options.h +++ b/src/kernel/mempool_options.h @@ -4,8 +4,13 @@ #ifndef BITCOIN_KERNEL_MEMPOOL_OPTIONS_H #define BITCOIN_KERNEL_MEMPOOL_OPTIONS_H +#include + class CBlockPolicyEstimator; +/** Default for -maxmempool, maximum megabytes of mempool memory usage */ +static constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300}; + namespace kernel { /** * Options struct containing options for constructing a CTxMemPool. Default @@ -19,6 +24,7 @@ struct MemPoolOptions { CBlockPolicyEstimator* estimator{nullptr}; /* The ratio used to determine how often sanity checks will run. */ int check_ratio{0}; + int64_t max_size_bytes{DEFAULT_MAX_MEMPOOL_SIZE_MB * 1'000'000}; }; } // namespace kernel -- cgit v1.2.3