| 143 | } |
| 144 | |
| 145 | static RPCMethod stop() |
| 146 | { |
| 147 | static const std::string RESULT{CLIENT_NAME " stopping"}; |
| 148 | return RPCMethod{ |
| 149 | "stop", |
| 150 | // Also accept the hidden 'wait' integer argument (milliseconds) |
| 151 | // For instance, 'stop 1000' makes the call wait 1 second before returning |
| 152 | // to the client (intended for testing) |
| 153 | "Request a graceful shutdown of " CLIENT_NAME ".", |
| 154 | { |
| 155 | {"wait", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "how long to wait in ms", RPCArgOptions{.hidden=true}}, |
| 156 | }, |
| 157 | RPCResult{RPCResult::Type::STR, "", "A string with the content '" + RESULT + "'"}, |
| 158 | RPCExamples{""}, |
| 159 | [](const RPCMethod& self, const JSONRPCRequest& jsonRequest) -> UniValue |
| 160 | { |
| 161 | // Event loop will exit after current HTTP requests have been handled, so |
| 162 | // this reply will get back to the client. |
| 163 | CHECK_NONFATAL((CHECK_NONFATAL(EnsureAnyNodeContext(jsonRequest.context).shutdown_request))()); |
| 164 | if (jsonRequest.params[0].isNum()) { |
| 165 | UninterruptibleSleep(std::chrono::milliseconds{jsonRequest.params[0].getInt<int>()}); |
| 166 | } |
| 167 | return RESULT; |
| 168 | }, |
| 169 | }; |
| 170 | } |
| 171 | |
| 172 | static RPCMethod uptime() |
| 173 | { |
no test coverage detected