| 1186 | } |
| 1187 | |
| 1188 | static 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 | |
| 1226 | static std::vector<RPCResult> OrphanDescription() |
| 1227 | { |
nothing calls this directly
no test coverage detected