Browse Source

Allow hush-cli stop to be run during RPC warmup, thanks to @zancas for the idea

pull/58/head
Duke Leto 5 years ago
parent
commit
1e980895b8
  1. 19
      src/rpc/server.cpp

19
src/rpc/server.cpp

@ -858,20 +858,25 @@ std::string JSONRPCExecBatch(const UniValue& vReq)
UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params) const
{
// 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)
throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
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());
// Find method
const CRPCCommand *pcmd = tableRPC[strMethod];
if (!pcmd)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
g_rpcSignals.PreCommand(*pcmd);
try

Loading…
Cancel
Save