MCPcopy Create free account
hub / github.com/ElementsProject/elements / savemempool

Function savemempool

src/rpc/blockchain.cpp:2566–2599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2564}
2565
2566static RPCHelpMan savemempool()
2567{
2568 return RPCHelpMan{"savemempool",
2569 "\nDumps the mempool to disk. It will fail until the previous dump is fully loaded.\n",
2570 {},
2571 RPCResult{
2572 RPCResult::Type::OBJ, "", "",
2573 {
2574 {RPCResult::Type::STR, "filename", "the directory and file where the mempool was saved"},
2575 }},
2576 RPCExamples{
2577 HelpExampleCli("savemempool", "")
2578 + HelpExampleRpc("savemempool", "")
2579 },
2580 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
2581{
2582 const ArgsManager& args{EnsureAnyArgsman(request.context)};
2583 const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
2584
2585 if (!mempool.IsLoaded()) {
2586 throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
2587 }
2588
2589 if (!DumpMempool(mempool)) {
2590 throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk");
2591 }
2592
2593 UniValue ret(UniValue::VOBJ);
2594 ret.pushKV("filename", fs::path((args.GetDataDirNet() / "mempool.dat")).u8string());
2595
2596 return ret;
2597},
2598 };
2599}
2600
2601namespace {
2602//! Search for a given set of pubkey scripts

Callers

nothing calls this directly

Calls 7

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
DumpMempoolFunction · 0.85
pathClass · 0.85
IsLoadedMethod · 0.80
pushKVMethod · 0.45

Tested by

no test coverage detected