1#include <xrpld/app/ledger/InboundLedgers.h>
2#include <xrpld/app/ledger/LedgerMaster.h>
3#include <xrpld/app/ledger/LedgerToJson.h>
4#include <xrpld/app/main/Application.h>
5#include <xrpld/app/misc/NetworkOPs.h>
6#include <xrpld/core/Config.h>
7#include <xrpld/rpc/Context.h>
8#include <xrpld/rpc/InfoSub.h>
9#include <xrpld/rpc/RPCHandler.h>
10#include <xrpld/rpc/Role.h>
11#include <xrpld/rpc/detail/Handler.h>
12#include <xrpld/rpc/detail/Tuning.h>
14#include <xrpl/basics/Log.h>
15#include <xrpl/core/JobQueue.h>
16#include <xrpl/core/PerfLog.h>
17#include <xrpl/json/to_string.h>
18#include <xrpl/protocol/ErrorCodes.h>
19#include <xrpl/protocol/jss.h>
20#include <xrpl/resource/Fees.h>
111fillHandler(JsonContext& context, Handler
const*& result)
116 int const jobCount = context.app.getJobQueue().getJobCountGE(
jtCLIENT);
119 JLOG(context.j.debug()) <<
"Too busy for command: " << jobCount;
124 if (!context.params.isMember(jss::command) && !context.params.isMember(jss::method))
126 if (context.params.isMember(jss::command) && context.params.isMember(jss::method))
128 if (context.params[jss::command].asString() != context.params[jss::method].asString())
132 std::string strCommand = context.params.isMember(jss::command) ? context.params[jss::command].asString()
133 : context.params[jss::method].asString();
135 JLOG(context.j.trace()) <<
"COMMAND:" << strCommand;
136 JLOG(context.j.trace()) <<
"REQUEST:" << context.params;
137 auto handler =
getHandler(context.apiVersion, context.app.config().BETA_RPC_API, strCommand);
155template <
class Object,
class Method>
157callMethod(JsonContext& context, Method method,
std::string const& name, Object& result)
160 auto& perfLog = context.app.getPerfLog();
164 perfLog.rpcStart(name, curId);
165 auto v = context.app.getJobQueue().makeLoadEvent(
jtGENERIC,
"cmd:" + name);
168 auto ret = method(context, result);
171 JLOG(context.j.debug()) <<
"RPC call " << name <<
" completed in " << ((
end - start).
count() / 1000000000.0)
173 perfLog.rpcFinish(name, curId);
178 perfLog.rpcError(name, curId);
179 JLOG(context.j.info()) <<
"Caught throw: " << e.
what();
194 Handler const* handler =
nullptr;
195 if (
auto error = fillHandler(context, handler))
208 auto ret = callMethod(context, method, handler->
name_, result);
217 auto ret = callMethod(context, method, handler->
name_, result);
233 return handler->role_;
Status
Return codes from Backend operations.
static int constexpr maxJobQueueClients
Role roleRequired(unsigned int version, bool betaEnabled, std::string const &method)
Handler const * getHandler(unsigned version, bool betaEnabled, std::string const &name)
Status doCommand(RPC::JsonContext &context, Json::Value &result)
Execute an RPC command and store the results in a Json::Value.
error_code_i conditionMet(Condition condition_required, T &context)
void inject_error(error_code_i code, Json::Value &json)
Add or update the json update to reflect the error code.
Charge const feeReferenceRPC
Charge const feeExceptionRPC
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Role
Indicates the level of administrative permission to grant.
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
Method< Json::Value > valueMethod_