Skip to content

Commit 91c91e1

Browse files
committed
Control mempool persistence using a command line parameter.
Mempool persistence was added in 3f78562, and is always on. This commit introduces a command-line parameter -persistmempool, which defaults to true. When set to false: - mempool.dat is not loaded when the node starts. - mempool.dat is not written when the node stops.
1 parent 02d64bd commit 91c91e1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/init.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ void Shutdown()
206206

207207
StopTorControl();
208208
UnregisterNodeSignals(GetNodeSignals());
209-
if (fDumpMempoolLater)
209+
if (fDumpMempoolLater && GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
210210
DumpMempool();
211+
}
211212

212213
if (fFeeEstimatesInitialized)
213214
{
@@ -339,6 +340,7 @@ std::string HelpMessage(HelpMessageMode mode)
339340
strUsage += HelpMessageOpt("-maxorphantx=<n>", strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
340341
strUsage += HelpMessageOpt("-maxmempool=<n>", strprintf(_("Keep the transaction memory pool below <n> megabytes (default: %u)"), DEFAULT_MAX_MEMPOOL_SIZE));
341342
strUsage += HelpMessageOpt("-mempoolexpiry=<n>", strprintf(_("Do not keep transactions in the mempool longer than <n> hours (default: %u)"), DEFAULT_MEMPOOL_EXPIRY));
343+
strUsage += HelpMessageOpt("-persistmempool", strprintf(_("Whether to save the mempool on shutdown and load on restart (default: %u)"), DEFAULT_PERSIST_MEMPOOL));
342344
strUsage += HelpMessageOpt("-blockreconstructionextratxn=<n>", strprintf(_("Extra transactions to keep in memory for compact block reconstructions (default: %u)"), DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN));
343345
strUsage += HelpMessageOpt("-par=<n>", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"),
344346
-GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
@@ -666,8 +668,10 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
666668
StartShutdown();
667669
}
668670
} // End scope of CImportingNow
669-
LoadMempool();
670-
fDumpMempoolLater = !fRequestShutdown;
671+
if (GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
672+
LoadMempool();
673+
fDumpMempoolLater = !fRequestShutdown;
674+
}
671675
}
672676

673677
/** Sanity checks

src/validation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
131131
static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
132132
static const bool DEFAULT_TXINDEX = false;
133133
static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
134-
134+
/** Default for -persistmempool */
135+
static const bool DEFAULT_PERSIST_MEMPOOL = true;
135136
/** Default for -mempoolreplacement */
136137
static const bool DEFAULT_ENABLE_REPLACEMENT = true;
137138
/** Default for using fee filter */

0 commit comments

Comments
 (0)