Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/server.cpp
| Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Note: This interface may still be subject to change. | * Note: This interface may still be subject to change. | ||||
| */ | */ | ||||
| std::string CRPCTable::help(Config &config, const std::string &strCommand, | std::string CRPCTable::help(Config &config, const std::string &strCommand, | ||||
| const JSONRPCRequest &helpreq) const { | const JSONRPCRequest &helpreq) const { | ||||
| std::string strRet; | std::string strRet; | ||||
| std::string category; | std::string category; | ||||
| std::set<rpcfn_type> setDone; | std::set<const CRPCCommand *> setDone; | ||||
| std::vector<std::pair<std::string, const CRPCCommand *>> vCommands; | std::vector<std::pair<std::string, const CRPCCommand *>> vCommands; | ||||
| for (std::map<std::string, const CRPCCommand *>::const_iterator mi = | for (std::map<std::string, const CRPCCommand *>::const_iterator mi = | ||||
| mapCommands.begin(); | mapCommands.begin(); | ||||
| mi != mapCommands.end(); ++mi) | mi != mapCommands.end(); ++mi) | ||||
| vCommands.push_back( | vCommands.push_back( | ||||
| std::make_pair(mi->second->category + mi->first, mi->second)); | std::make_pair(mi->second->category + mi->first, mi->second)); | ||||
| sort(vCommands.begin(), vCommands.end()); | sort(vCommands.begin(), vCommands.end()); | ||||
| Show All 15 Lines | for (const std::pair<std::string, const CRPCCommand *> &command : | ||||
| strMethod != strCommand) { | strMethod != strCommand) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| jreq.strMethod = strMethod; | jreq.strMethod = strMethod; | ||||
| try { | try { | ||||
| JSONRPCRequest jreq; | JSONRPCRequest jreq; | ||||
| jreq.fHelp = true; | jreq.fHelp = true; | ||||
| rpcfn_type pfn = pcmd->actor; | if (setDone.insert(pcmd).second) pcmd->call(config, jreq); | ||||
deadalnix: Braces | |||||
| if (setDone.insert(pfn).second) pfn(config, jreq); | |||||
| } catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
| // Help text is returned in an exception | // Help text is returned in an exception | ||||
| std::string strHelp = std::string(e.what()); | std::string strHelp = std::string(e.what()); | ||||
| if (strCommand == "") { | if (strCommand == "") { | ||||
| if (strHelp.find('\n') != std::string::npos) | if (strHelp.find('\n') != std::string::npos) | ||||
| strHelp = strHelp.substr(0, strHelp.find('\n')); | strHelp = strHelp.substr(0, strHelp.find('\n')); | ||||
| if (category != pcmd->category) { | if (category != pcmd->category) { | ||||
| ▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | UniValue CRPCTable::execute(Config &config, | ||||
| const CRPCCommand *pcmd = tableRPC[request.strMethod]; | const CRPCCommand *pcmd = tableRPC[request.strMethod]; | ||||
| if (!pcmd) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); | if (!pcmd) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); | ||||
| g_rpcSignals.PreCommand(*pcmd); | g_rpcSignals.PreCommand(*pcmd); | ||||
| try { | try { | ||||
| // Execute, convert arguments to array if necessary | // Execute, convert arguments to array if necessary | ||||
| if (request.params.isObject()) { | if (request.params.isObject()) { | ||||
| return pcmd->actor( | return pcmd->call(config, | ||||
| config, transformNamedArguments(request, pcmd->argNames)); | transformNamedArguments(request, pcmd->argNames)); | ||||
| } else { | } else { | ||||
| return pcmd->actor(config, request); | return pcmd->call(config, request); | ||||
| } | } | ||||
| } catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
| throw JSONRPCError(RPC_MISC_ERROR, e.what()); | throw JSONRPCError(RPC_MISC_ERROR, e.what()); | ||||
| } | } | ||||
| g_rpcSignals.PostCommand(*pcmd); | g_rpcSignals.PostCommand(*pcmd); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines | |||||
Braces