diff options
author | João Barbosa <joao.paulo.barbosa@gmail.com> | 2018-11-20 17:52:15 +0000 |
---|---|---|
committer | João Barbosa <joao.paulo.barbosa@gmail.com> | 2018-11-23 16:54:22 +0000 |
commit | 02e1e4eff6cda0bfc24b455a7c1583394cbff6eb (patch) | |
tree | 237289b00a226826bf8a34b05e59fd228bd193e0 /src | |
parent | 59f05d1161698dcca6eaf719422d4ec3401f2954 (diff) |
rpc: Add wait argument to stop
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/client.cpp | 1 | ||||
-rw-r--r-- | src/rpc/server.cpp | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 2b99808c07..6f1bfb03d1 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -162,6 +162,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "rescanblockchain", 1, "stop_height"}, { "createwallet", 1, "disable_private_keys"}, { "getnodeaddresses", 0, "count"}, + { "stop", 0, "wait" }, }; // clang-format on diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index c565094a10..865d343eb2 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -227,6 +227,9 @@ UniValue help(const JSONRPCRequest& jsonRequest) UniValue stop(const JSONRPCRequest& jsonRequest) { // 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) throw std::runtime_error( RPCHelpMan{"stop", @@ -235,6 +238,9 @@ UniValue stop(const JSONRPCRequest& jsonRequest) // Event loop will exit after current HTTP requests have been handled, so // this reply will get back to the client. StartShutdown(); + if (jsonRequest.params[0].isNum()) { + MilliSleep(jsonRequest.params[0].get_int()); + } return "Bitcoin server stopping"; } @@ -264,7 +270,7 @@ static const CRPCCommand vRPCCommands[] = // --------------------- ------------------------ ----------------------- ---------- /* Overall control/query calls */ { "control", "help", &help, {"command"} }, - { "control", "stop", &stop, {} }, + { "control", "stop", &stop, {"wait"} }, { "control", "uptime", &uptime, {} }, }; // clang-format on |