Skip to content

Commit 1134686

Browse files
committed
mempool: Don't share mempool with dbcache in blocksonly
When -blockonly is set, reduce mempool size to 5MB unless -maxmempool is also set. See #9569
1 parent 8339f3c commit 1134686

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/init.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,13 @@ void InitParameterInteraction(ArgsManager& args)
719719
LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
720720
}
721721

722-
// disable whitelistrelay in blocksonly mode
723722
if (args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) {
723+
// disable whitelistrelay in blocksonly mode
724724
if (args.SoftSetBoolArg("-whitelistrelay", false))
725725
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
726+
// Reduce default mempool size in blocksonly mode to avoid unexpected resource usage
727+
if (args.SoftSetArg("-maxmempool", ToString(DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB)))
728+
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -maxmempool=%d\n", __func__, DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB);
726729
}
727730

728731
// Forcing relay from whitelisted hosts implies we will accept relays from them in the first place.

src/kernel/mempool_options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class CBlockPolicyEstimator;
1818

1919
/** Default for -maxmempool, maximum megabytes of mempool memory usage */
2020
static constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300};
21+
//** Default for -maxmempool when blocksonly is set */
22+
static constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5};
2123
/** Default for -mempoolexpiry, expiration time for mempool transactions in hours */
2224
static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336};
2325
/** Default for -mempoolfullrbf, if the transaction replaceability signaling is ignored */

0 commit comments

Comments
 (0)