diff options
Diffstat (limited to 'src/rpc/server.cpp')
-rw-r--r-- | src/rpc/server.cpp | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 19063fa5be..086f609ac3 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -11,6 +11,7 @@ #include <common/system.h> #include <logging.h> #include <node/context.h> +#include <node/kernel_notifications.h> #include <rpc/server_util.h> #include <rpc/util.h> #include <sync.h> @@ -18,8 +19,7 @@ #include <util/strencodings.h> #include <util/string.h> #include <util/time.h> - -#include <boost/signals2/signal.hpp> +#include <validation.h> #include <cassert> #include <chrono> @@ -69,22 +69,6 @@ struct RPCCommandExecution } }; -static struct CRPCSignals -{ - boost::signals2::signal<void ()> Started; - boost::signals2::signal<void ()> Stopped; -} g_rpcSignals; - -void RPCServer::OnStarted(std::function<void ()> slot) -{ - g_rpcSignals.Started.connect(slot); -} - -void RPCServer::OnStopped(std::function<void ()> slot) -{ - g_rpcSignals.Stopped.connect(slot); -} - std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& helpreq) const { std::string strRet; @@ -295,9 +279,8 @@ bool CRPCTable::removeCommand(const std::string& name, const CRPCCommand* pcmd) void StartRPC() { - LogPrint(BCLog::RPC, "Starting RPC\n"); + LogDebug(BCLog::RPC, "Starting RPC\n"); g_rpc_running = true; - g_rpcSignals.Started(); } void InterruptRPC() @@ -305,22 +288,25 @@ void InterruptRPC() static std::once_flag g_rpc_interrupt_flag; // This function could be called twice if the GUI has been started with -server=1. std::call_once(g_rpc_interrupt_flag, []() { - LogPrint(BCLog::RPC, "Interrupting RPC\n"); + LogDebug(BCLog::RPC, "Interrupting RPC\n"); // Interrupt e.g. running longpolls g_rpc_running = false; }); } -void StopRPC() +void StopRPC(const std::any& context) { static std::once_flag g_rpc_stop_flag; // This function could be called twice if the GUI has been started with -server=1. assert(!g_rpc_running); - std::call_once(g_rpc_stop_flag, []() { - LogPrint(BCLog::RPC, "Stopping RPC\n"); + std::call_once(g_rpc_stop_flag, [&]() { + LogDebug(BCLog::RPC, "Stopping RPC\n"); WITH_LOCK(g_deadline_timers_mutex, deadlineTimers.clear()); DeleteAuthCookie(); - g_rpcSignals.Stopped(); + node::NodeContext& node = EnsureAnyNodeContext(context); + // The notifications interface doesn't exist between initialization step 4a and 7. + if (node.notifications) node.notifications->m_tip_block_cv.notify_all(); + LogDebug(BCLog::RPC, "RPC stopped.\n"); }); } @@ -583,7 +569,7 @@ void RPCRunLater(const std::string& name, std::function<void()> func, int64_t nS throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC"); LOCK(g_deadline_timers_mutex); deadlineTimers.erase(name); - LogPrint(BCLog::RPC, "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name()); + LogDebug(BCLog::RPC, "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name()); deadlineTimers.emplace(name, std::unique_ptr<RPCTimerBase>(timerInterface->NewTimer(func, nSeconds*1000))); } |