mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
rpc: Add wait argument to stop
This commit is contained in:
parent
59f05d1161
commit
02e1e4eff6
2 changed files with 8 additions and 1 deletions
|
@ -162,6 +162,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||||
{ "rescanblockchain", 1, "stop_height"},
|
{ "rescanblockchain", 1, "stop_height"},
|
||||||
{ "createwallet", 1, "disable_private_keys"},
|
{ "createwallet", 1, "disable_private_keys"},
|
||||||
{ "getnodeaddresses", 0, "count"},
|
{ "getnodeaddresses", 0, "count"},
|
||||||
|
{ "stop", 0, "wait" },
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -227,6 +227,9 @@ UniValue help(const JSONRPCRequest& jsonRequest)
|
||||||
UniValue stop(const JSONRPCRequest& jsonRequest)
|
UniValue stop(const JSONRPCRequest& jsonRequest)
|
||||||
{
|
{
|
||||||
// Accept the deprecated and ignored 'detach' boolean argument
|
// Accept the deprecated and ignored 'detach' boolean argument
|
||||||
|
// Also accept the hidden 'wait' integer argument (milliseconds)
|
||||||
|
// For instance, 'stop 1000' makes the call wait 1 second before returning
|
||||||
|
// to the client (intended for testing)
|
||||||
if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
|
if (jsonRequest.fHelp || jsonRequest.params.size() > 1)
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
RPCHelpMan{"stop",
|
RPCHelpMan{"stop",
|
||||||
|
@ -235,6 +238,9 @@ UniValue stop(const JSONRPCRequest& jsonRequest)
|
||||||
// Event loop will exit after current HTTP requests have been handled, so
|
// Event loop will exit after current HTTP requests have been handled, so
|
||||||
// this reply will get back to the client.
|
// this reply will get back to the client.
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
|
if (jsonRequest.params[0].isNum()) {
|
||||||
|
MilliSleep(jsonRequest.params[0].get_int());
|
||||||
|
}
|
||||||
return "Bitcoin server stopping";
|
return "Bitcoin server stopping";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +270,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||||
// --------------------- ------------------------ ----------------------- ----------
|
// --------------------- ------------------------ ----------------------- ----------
|
||||||
/* Overall control/query calls */
|
/* Overall control/query calls */
|
||||||
{ "control", "help", &help, {"command"} },
|
{ "control", "help", &help, {"command"} },
|
||||||
{ "control", "stop", &stop, {} },
|
{ "control", "stop", &stop, {"wait"} },
|
||||||
{ "control", "uptime", &uptime, {} },
|
{ "control", "uptime", &uptime, {} },
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
Loading…
Add table
Reference in a new issue