Skip to content

Commit 2776ba1

Browse files
committed
Abstract minimum maxmempool to maxmempoolMinimumBytes function (in txmempool)
1 parent f06545d commit 2776ba1

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/rpc/mempool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ static RPCHelpMan maxmempool()
394394
CTxMemPool& mempool = EnsureAnyMemPool(request.context);
395395
LOCK(mempool.cs);
396396

397-
int64_t nMempoolSizeMin = mempool.m_opts.limits.descendant_size_vbytes * 40;
397+
int64_t nMempoolSizeMin = maxmempoolMinimumBytes(mempool.m_opts.limits.descendant_size_vbytes);
398398
if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
399399
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("MaxMempool size %d is too small", nSize));
400400
mempool.m_opts.max_size_bytes = nSize;

src/txmempool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int32_t modifySize, CAmount modifyFee,
401401
static CTxMemPool::Options&& Flatten(CTxMemPool::Options&& opts, bilingual_str& error)
402402
{
403403
opts.check_ratio = std::clamp<int>(opts.check_ratio, 0, 1'000'000);
404-
int64_t descendant_limit_bytes = opts.limits.descendant_size_vbytes * 40;
404+
int64_t descendant_limit_bytes = maxmempoolMinimumBytes(opts.limits.descendant_size_vbytes);
405405
if (opts.max_size_bytes < 0 || opts.max_size_bytes < descendant_limit_bytes) {
406406
error = strprintf(_("-maxmempool must be at least %d MB"), std::ceil(descendant_limit_bytes / 1'000'000.0));
407407
}

src/txmempool.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ struct bilingual_str;
4848
/** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */
4949
static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
5050

51+
inline int64_t maxmempoolMinimumBytes(const int64_t descendant_size_vbytes) {
52+
return descendant_size_vbytes * 40;
53+
}
54+
5155
/**
5256
* Test whether the LockPoints height and time are still valid on the current chain
5357
*/

0 commit comments

Comments
 (0)