mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 23:42:33 +02:00
refactor: Add RPC server ExecuteCommands function
No change in behavior. New function is split from CRPCTable::execute and used in the next commit.
This commit is contained in:
parent
6158a6d397
commit
14f3d9b908
@ -437,6 +437,16 @@ static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, c
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ExecuteCommands(const std::vector<const CRPCCommand*>& commands, const JSONRPCRequest& request, UniValue& result)
|
||||||
|
{
|
||||||
|
for (const auto& command : commands) {
|
||||||
|
if (ExecuteCommand(*command, request, result, &command == &commands.back())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
UniValue CRPCTable::execute(const JSONRPCRequest &request) const
|
UniValue CRPCTable::execute(const JSONRPCRequest &request) const
|
||||||
{
|
{
|
||||||
// Return immediately if in warmup
|
// Return immediately if in warmup
|
||||||
@ -450,10 +460,8 @@ UniValue CRPCTable::execute(const JSONRPCRequest &request) const
|
|||||||
auto it = mapCommands.find(request.strMethod);
|
auto it = mapCommands.find(request.strMethod);
|
||||||
if (it != mapCommands.end()) {
|
if (it != mapCommands.end()) {
|
||||||
UniValue result;
|
UniValue result;
|
||||||
for (const auto& command : it->second) {
|
if (ExecuteCommands(it->second, request, result)) {
|
||||||
if (ExecuteCommand(*command, request, result, &command == &it->second.back())) {
|
return result;
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
|
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
|
||||||
|
Loading…
Reference in New Issue
Block a user