20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/main/Application.h>
22 #include <ripple/app/misc/NetworkOPs.h>
23 #include <ripple/app/reporting/P2pProxy.h>
24 #include <ripple/basics/Log.h>
25 #include <ripple/basics/PerfLog.h>
26 #include <ripple/basics/contract.h>
27 #include <ripple/core/Config.h>
28 #include <ripple/core/JobQueue.h>
29 #include <ripple/json/Object.h>
30 #include <ripple/json/to_string.h>
31 #include <ripple/net/InfoSub.h>
32 #include <ripple/net/RPCErr.h>
33 #include <ripple/protocol/jss.h>
34 #include <ripple/resource/Fees.h>
35 #include <ripple/rpc/RPCHandler.h>
36 #include <ripple/rpc/Role.h>
37 #include <ripple/rpc/impl/Handler.h>
38 #include <ripple/rpc/impl/Tuning.h>
128 fillHandler(JsonContext& context, Handler
const*& result)
133 int const jobCount = context.app.getJobQueue().getJobCountGE(
jtCLIENT);
136 JLOG(context.j.debug()) <<
"Too busy for command: " << jobCount;
141 if (!context.params.isMember(jss::command) &&
142 !context.params.isMember(jss::method))
144 if (context.params.isMember(jss::command) &&
145 context.params.isMember(jss::method))
147 if (context.params[jss::command].asString() !=
148 context.params[jss::method].asString())
152 std::string strCommand = context.params.isMember(jss::command)
153 ? context.params[jss::command].asString()
154 : context.params[jss::method].asString();
156 JLOG(context.j.trace()) <<
"COMMAND:" << strCommand;
157 JLOG(context.j.trace()) <<
"REQUEST:" << context.params;
159 context.apiVersion, context.app.config().BETA_RPC_API, strCommand);
177 template <
class Object,
class Method>
180 JsonContext& context,
186 auto& perfLog = context.app.getPerfLog();
190 perfLog.rpcStart(name, curId);
192 context.app.getJobQueue().makeLoadEvent(
jtGENERIC,
"cmd:" + name);
195 auto ret = method(context, result);
198 JLOG(context.j.debug())
199 <<
"RPC call " << name <<
" completed in "
200 << ((
end - start).
count() / 1000000000.0) <<
"seconds";
201 perfLog.rpcFinish(name, curId);
204 catch (ReportingShouldProxy&)
211 perfLog.rpcError(name, curId);
212 JLOG(context.j.info()) <<
"Caught throw: " << e.
what();
233 "This is a reporting server. "
234 " The default behavior of a reporting server is to only"
235 " return validated data. If you are looking for not yet"
236 " validated data, include \"ledger_index : current\""
237 " in your request, which will cause this server to forward"
238 " the request to a p2p node. If the forward is successful"
239 " the response will include \"forwarded\" : \"true\"";
240 result[jss::warnings] = std::move(warnings);
254 Handler const* handler =
nullptr;
255 if (
auto error = fillHandler(context, handler))
267 <<
"start command: " << handler->
name_
271 auto ret = callMethod(context, method, handler->
name_, result);
274 <<
"finish command: " << handler->
name_
282 auto ret = callMethod(context, method, handler->
name_, result);
299 return handler->role_;