MCPcopy Create free account
hub / github.com/ElementsProject/elements / help

Method help

src/rpc/server.cpp:79–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& helpreq) const
80{
81 std::string strRet;
82 std::string category;
83 std::set<intptr_t> setDone;
84 std::vector<std::pair<std::string, const CRPCCommand*> > vCommands;
85
86 for (const auto& entry : mapCommands)
87 vCommands.push_back(make_pair(entry.second.front()->category + entry.first, entry.second.front()));
88 sort(vCommands.begin(), vCommands.end());
89
90 JSONRPCRequest jreq = helpreq;
91 jreq.mode = JSONRPCRequest::GET_HELP;
92 jreq.params = UniValue();
93
94 for (const std::pair<std::string, const CRPCCommand*>& command : vCommands)
95 {
96 const CRPCCommand *pcmd = command.second;
97 std::string strMethod = pcmd->name;
98 if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
99 continue;
100 jreq.strMethod = strMethod;
101 try
102 {
103 UniValue unused_result;
104 if (setDone.insert(pcmd->unique_id).second)
105 pcmd->actor(jreq, unused_result, true /* last_handler */);
106 }
107 catch (const std::exception& e)
108 {
109 // Help text is returned in an exception
110 std::string strHelp = std::string(e.what());
111 if (strCommand == "")
112 {
113 if (strHelp.find('\n') != std::string::npos)
114 strHelp = strHelp.substr(0, strHelp.find('\n'));
115
116 if (category != pcmd->category)
117 {
118 if (!category.empty())
119 strRet += "\n";
120 category = pcmd->category;
121 strRet += "== " + Capitalize(category) + " ==\n";
122 }
123 }
124 strRet += strHelp + "\n";
125 }
126 }
127 if (strRet == "")
128 strRet = strprintf("help: unknown command: %s\n", strCommand);
129 strRet = strRet.substr(0,strRet.size()-1);
130 return strRet;
131}
132
133static RPCHelpMan help()
134{

Callers 15

run_testMethod · 0.80
test_categoriesMethod · 0.80
dump_helpMethod · 0.80
write_all_rpc_commandsFunction · 0.80
test_getpeerinfoMethod · 0.80
test_getnetworkinfoMethod · 0.80
test_addpeeraddressMethod · 0.80
run_testMethod · 0.80
run_testMethod · 0.80
run_testMethod · 0.80
test_categoriesMethod · 0.80

Calls 9

CapitalizeFunction · 0.85
findMethod · 0.80
UniValueClass · 0.70
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 6

test_categoriesMethod · 0.64
test_getpeerinfoMethod · 0.64
test_getnetworkinfoMethod · 0.64
test_addpeeraddressMethod · 0.64
test_categoriesMethod · 0.64