| 2564 | } |
| 2565 | |
| 2566 | static 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 | |
| 2601 | namespace { |
| 2602 | //! Search for a given set of pubkey scripts |
nothing calls this directly
no test coverage detected