Adds a stopdetach <detach> RPC command. <detach> defaults to true. Works just like stop, but overrides the commandline/config file

-detachdb option.  Useful for upgrading, for example.  Lets you use fast stops usually, but force a detach when needed.  Also, allows
you to do a fast stop in a system normally configured for fast stops.
This commit is contained in:
kjj2 2012-09-18 21:54:43 -05:00
parent 6cbae37667
commit 3731f5788e

View File

@ -9,6 +9,7 @@
#include "ui_interface.h" #include "ui_interface.h"
#include "base58.h" #include "base58.h"
#include "bitcoinrpc.h" #include "bitcoinrpc.h"
#include "db.h"
#undef printf #undef printf
#include <boost/asio.hpp> #include <boost/asio.hpp>
@ -173,11 +174,14 @@ Value help(const Array& params, bool fHelp)
Value stop(const Array& params, bool fHelp) Value stop(const Array& params, bool fHelp)
{ {
if (fHelp || params.size() != 0) if (fHelp || params.size() > 1)
throw runtime_error( throw runtime_error(
"stop\n" "stop <detach>\n"
"Stop Bitcoin server."); "<detach> is true or false to detach the database or not for this stop only\n"
"Stop Bitcoin server (and possibly override the detachdb config value).");
// Shutdown will take long enough that the response should get back // Shutdown will take long enough that the response should get back
if (params.size() > 0)
bitdb.SetDetach(params[0].get_bool());
StartShutdown(); StartShutdown();
return "Bitcoin server stopping"; return "Bitcoin server stopping";
} }
@ -1126,6 +1130,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
// //
// Special case non-string parameter types // Special case non-string parameter types
// //
if (strMethod == "stop" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "setgenerate" && n > 0) ConvertTo<bool>(params[0]); if (strMethod == "setgenerate" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]); if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]); if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);