DumpMempool: Pass in dump_path, stop using gArgs

Also introduce node::{ShouldPersistMempool,MempoolPath} helper functions
in node/mempool_persist_args.{h,cpp} which are used by non-kernel
DumpMempool callers to determine whether or not to automatically dump
the mempool and where to dump it to.
This commit is contained in:
Carl Dong
2022-07-12 15:54:11 -04:00
parent bd4407817e
commit 413f4bb52b
8 changed files with 64 additions and 9 deletions

View File

@@ -41,6 +41,7 @@
#include <node/chainstate.h>
#include <node/context.h>
#include <node/interface_ui.h>
#include <node/mempool_persist_args.h>
#include <node/miner.h>
#include <policy/feerate.h>
#include <policy/fees.h>
@@ -111,6 +112,8 @@ using node::CleanupBlockRevFiles;
using node::DEFAULT_PRINTPRIORITY;
using node::DEFAULT_STOPAFTERBLOCKIMPORT;
using node::LoadChainstate;
using node::MempoolPath;
using node::ShouldPersistMempool;
using node::NodeContext;
using node::ThreadImport;
using node::VerifyLoadedChainstate;
@@ -246,8 +249,8 @@ void Shutdown(NodeContext& node)
node.addrman.reset();
node.netgroupman.reset();
if (node.mempool && node.mempool->IsLoaded() && node.args->GetBoolArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
DumpMempool(*node.mempool);
if (node.mempool && node.mempool->IsLoaded() && ShouldPersistMempool(*node.args)) {
DumpMempool(*node.mempool, MempoolPath(*node.args));
}
// Drop transactions we were still watching, and record fee estimations.