20#include <xrpld/app/ledger/InboundLedgers.h>
21#include <xrpld/app/ledger/LedgerMaster.h>
22#include <xrpld/app/ledger/LedgerToJson.h>
23#include <xrpld/app/main/Application.h>
24#include <xrpld/app/misc/NetworkOPs.h>
25#include <xrpld/core/Config.h>
26#include <xrpld/core/JobQueue.h>
27#include <xrpld/net/InfoSub.h>
28#include <xrpld/perflog/PerfLog.h>
29#include <xrpld/rpc/Context.h>
30#include <xrpld/rpc/RPCHandler.h>
31#include <xrpld/rpc/Role.h>
32#include <xrpld/rpc/detail/Handler.h>
33#include <xrpld/rpc/detail/Tuning.h>
34#include <xrpl/basics/Log.h>
35#include <xrpl/basics/contract.h>
36#include <xrpl/json/Object.h>
37#include <xrpl/json/to_string.h>
38#include <xrpl/protocol/ErrorCodes.h>
39#include <xrpl/protocol/RPCErr.h>
40#include <xrpl/protocol/jss.h>
41#include <xrpl/resource/Fees.h>
132fillHandler(JsonContext& context, Handler
const*& result)
137 int const jobCount = context.app.getJobQueue().getJobCountGE(
jtCLIENT);
140 JLOG(context.j.debug()) <<
"Too busy for command: " << jobCount;
145 if (!context.params.isMember(jss::command) &&
146 !context.params.isMember(jss::method))
148 if (context.params.isMember(jss::command) &&
149 context.params.isMember(jss::method))
151 if (context.params[jss::command].asString() !=
152 context.params[jss::method].asString())
156 std::string strCommand = context.params.isMember(jss::command)
157 ? context.params[jss::command].asString()
158 : context.params[jss::method].asString();
160 JLOG(context.j.trace()) <<
"COMMAND:" << strCommand;
161 JLOG(context.j.trace()) <<
"REQUEST:" << context.params;
163 context.apiVersion, context.app.config().BETA_RPC_API, strCommand);
181template <
class Object,
class Method>
184 JsonContext& context,
190 auto& perfLog = context.app.getPerfLog();
194 perfLog.rpcStart(name, curId);
196 context.app.getJobQueue().makeLoadEvent(
jtGENERIC,
"cmd:" + name);
199 auto ret = method(context, result);
202 JLOG(context.j.debug())
203 <<
"RPC call " << name <<
" completed in "
204 << ((
end - start).
count() / 1000000000.0) <<
"seconds";
205 perfLog.rpcFinish(name, curId);
210 perfLog.rpcError(name, curId);
211 JLOG(context.j.info()) <<
"Caught throw: " << e.
what();
226 Handler const* handler =
nullptr;
227 if (
auto error = fillHandler(context, handler))
239 <<
"start command: " << handler->
name_
243 auto ret = callMethod(context, method, handler->
name_, result);
246 <<
"finish command: " << handler->
name_
254 auto ret = callMethod(context, method, handler->
name_, result);
270 return handler->role_;
Status
Return codes from Backend operations.
static int constexpr maxJobQueueClients
Role roleRequired(unsigned int version, bool betaEnabled, std::string const &method)
void inject_error(error_code_i code, JsonValue &json)
Add or update the json update to reflect the error code.
Status doCommand(RPC::JsonContext &context, Json::Value &result)
Execute an RPC command and store the results in a Json::Value.
Handler const * getHandler(unsigned version, bool betaEnabled, std::string const &name)
error_code_i conditionMet(Condition condition_required, T &context)
Charge const feeReferenceRPC
Charge const feeExceptionRPC
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
Role
Indicates the level of administrative permission to grant.
Method< Json::Value > valueMethod_