Allow hush-cli stop to be run during RPC warmup, thanks to @zancas for the idea
This commit is contained in:
@@ -858,20 +858,25 @@ std::string JSONRPCExecBatch(const UniValue& vReq)
|
|||||||
|
|
||||||
UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms) const
|
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
|
// Find method
|
||||||
const CRPCCommand *pcmd = tableRPC[strMethod];
|
const CRPCCommand *pcmd = tableRPC[strMethod];
|
||||||
if (!pcmd)
|
if (!pcmd)
|
||||||
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
|
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);
|
g_rpcSignals.PreCommand(*pcmd);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user