From 4401b2d7c52e0f3841225369fb0d10767c51aaa2 Mon Sep 17 00:00:00 2001 From: Eric Lombrozo Date: Sun, 19 Oct 2014 04:46:17 -0400 Subject: Removed main.h dependency from rpcserver.cpp Rebased by @laanwj: - update for RPC methods added since 84d13ee: setmocktime, invalidateblock, reconsiderblock. Only the first, setmocktime, required a change, the other two are thread safe. --- src/init.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index aaa5f06c75..7054264c0b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -234,6 +234,26 @@ bool static Bind(const CService &addr, unsigned int flags) { return true; } +void OnRPCStopped() +{ + cvBlockChange.notify_all(); + LogPrint("rpc", "RPC stopped.\n"); +} + +void OnRPCPreCommand(const CRPCCommand& cmd) +{ +#ifdef ENABLE_WALLET + if (cmd.reqWallet && !pwalletMain) + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)"); +#endif + + // Observe safe mode + string strWarning = GetWarnings("rpc"); + if (strWarning != "" && !GetBoolArg("-disablesafemode", false) && + !cmd.okSafeMode) + throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning); +} + std::string HelpMessage(HelpMessageMode mode) { // When adding new options to the categories, please keep and ensure alphabetical ordering. @@ -802,6 +822,8 @@ bool AppInit2(boost::thread_group& threadGroup) if (fServer) { uiInterface.InitMessage.connect(SetRPCWarmupStatus); + RPCServer::OnStopped(&OnRPCStopped); + RPCServer::OnPreCommand(&OnRPCPreCommand); StartRPCThreads(); } -- cgit v1.2.3