From 1e980895b8c4754550bf7ac5da2cb9ba1aee0994 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 16 Dec 2019 08:45:18 -0500 Subject: [PATCH] Allow hush-cli stop to be run during RPC warmup, thanks to @zancas for the idea --- src/rpc/server.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index a554f77cf..946dc411c 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -858,20 +858,25 @@ std::string JSONRPCExecBatch(const UniValue& vReq) UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms) const { - // Return immediately if in warmup - { - LOCK(cs_rpcWarmup); - if (fRPCInWarmup) - throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus); - } - - //printf("RPC call: %s\n", strMethod.c_str()); - // Find method const CRPCCommand *pcmd = tableRPC[strMethod]; if (!pcmd) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); + // Return immediately if in warmup + { + LOCK(cs_rpcWarmup); + if (fRPCInWarmup) { + // hush-cli stop is the only valid RPC command during warmup + // We don't know if we have valid blocks or wallet yet, nothing else is safe + if (pcmd->name != "stop") { + throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus); + } + } + } + + //printf("RPC call: %s\n", strMethod.c_str()); + g_rpcSignals.PreCommand(*pcmd); try