MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / savemempool

Function savemempool

src/rpc/mempool.cpp:1188–1224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1186}
1187
1188static RPCMethod savemempool()
1189{
1190 return RPCMethod{
1191 "savemempool",
1192 "Dumps the mempool to disk. It will fail until the previous dump is fully loaded.\n",
1193 {},
1194 RPCResult{
1195 RPCResult::Type::OBJ, "", "",
1196 {
1197 {RPCResult::Type::STR, "filename", "the directory and file where the mempool was saved"},
1198 }},
1199 RPCExamples{
1200 HelpExampleCli("savemempool", "")
1201 + HelpExampleRpc("savemempool", "")
1202 },
1203 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
1204{
1205 const ArgsManager& args{EnsureAnyArgsman(request.context)};
1206 const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
1207
1208 if (!mempool.GetLoadTried()) {
1209 throw JSONRPCError(RPC_MISC_ERROR, "The mempool was not loaded yet");
1210 }
1211
1212 const fs::path& dump_path = MempoolPath(args);
1213
1214 if (!DumpMempool(mempool, dump_path)) {
1215 throw JSONRPCError(RPC_MISC_ERROR, "Unable to dump mempool to disk");
1216 }
1217
1218 UniValue ret(UniValue::VOBJ);
1219 ret.pushKV("filename", dump_path.utf8string());
1220
1221 return ret;
1222},
1223 };
1224}
1225
1226static std::vector<RPCResult> OrphanDescription()
1227{

Callers

nothing calls this directly

Calls 8

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
MempoolPathFunction · 0.85
DumpMempoolFunction · 0.85
GetLoadTriedMethod · 0.80
pushKVMethod · 0.80
utf8stringMethod · 0.80

Tested by

no test coverage detected