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

Function stop

src/rpc/server.cpp:145–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145static 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
172static RPCMethod uptime()
173{

Callers 2

~WalletLoaderImplMethod · 0.85
~ClientModelMethod · 0.85

Calls 2

UninterruptibleSleepFunction · 0.85
isNumMethod · 0.80

Tested by

no test coverage detected