MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / help

Method help

src/rpc/server.cpp:123–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123std::string CRPCTable::help(const Config &config, const std::string &strCommand,
124 const JSONRPCRequest &helpreq) const {
125 std::string strRet;
126 std::string category;
127 std::set<intptr_t> setDone;
128 std::vector<std::pair<std::string, const CRPCCommand *>> vCommands;
129 vCommands.reserve(mapCommands.size());
130
131 for (const auto &entry : mapCommands) {
132 vCommands.push_back(
133 std::make_pair(entry.second.front()->category + entry.first,
134 entry.second.front()));
135 }
136 sort(vCommands.begin(), vCommands.end());
137
138 JSONRPCRequest jreq = helpreq;
139 jreq.mode = JSONRPCRequest::GET_HELP;
140 jreq.params = UniValue();
141
142 for (const std::pair<std::string, const CRPCCommand *> &command :
143 vCommands) {
144 const CRPCCommand *pcmd = command.second;
145 std::string strMethod = pcmd->name;
146 if ((strCommand != "" || pcmd->category == "hidden") &&
147 strMethod != strCommand) {
148 continue;
149 }
150
151 jreq.strMethod = strMethod;
152 try {
153 UniValue unused_result;
154 if (setDone.insert(pcmd->unique_id).second) {
155 pcmd->actor(config, jreq, unused_result,
156 true /* last_handler */);
157 }
158 } catch (const std::exception &e) {
159 // Help text is returned in an exception
160 std::string strHelp = std::string(e.what());
161 if (strCommand == "") {
162 if (strHelp.find('\n') != std::string::npos) {
163 strHelp = strHelp.substr(0, strHelp.find('\n'));
164 }
165
166 if (category != pcmd->category) {
167 if (!category.empty()) {
168 strRet += "\n";
169 }
170 category = pcmd->category;
171 strRet += "== " + Capitalize(category) + " ==\n";
172 }
173 }
174 strRet += strHelp + "\n";
175 }
176 }
177 if (strRet == "") {
178 strRet = strprintf("help: unknown command: %s\n", strCommand);
179 }
180

Callers 12

test_getpeerinfoMethod · 0.45
test_getnetworkinfoMethod · 0.45
test_addpeeraddressMethod · 0.45
run_testMethod · 0.45
run_testMethod · 0.45
run_testMethod · 0.45
test_categoriesMethod · 0.45
dump_helpMethod · 0.45
wallet_helpMethod · 0.45
write_all_rpc_commandsFunction · 0.45
helpFunction · 0.45

Calls 12

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

Tested by 5

test_getpeerinfoMethod · 0.36
test_getnetworkinfoMethod · 0.36
test_addpeeraddressMethod · 0.36
test_categoriesMethod · 0.36