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/core/JobQueue.h>
8#include <xrpld/perflog/PerfLog.h>
9#include <xrpld/rpc/Context.h>
10#include <xrpld/rpc/InfoSub.h>
11#include <xrpld/rpc/RPCHandler.h>
12#include <xrpld/rpc/Role.h>
13#include <xrpld/rpc/detail/Handler.h>
14#include <xrpld/rpc/detail/Tuning.h>
16#include <xrpl/basics/Log.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) &&
125 !context.params.isMember(jss::method))
127 if (context.params.isMember(jss::command) &&
128 context.params.isMember(jss::method))
130 if (context.params[jss::command].asString() !=
131 context.params[jss::method].asString())
135 std::string strCommand = context.params.isMember(jss::command)
136 ? context.params[jss::command].asString()
137 : context.params[jss::method].asString();
139 JLOG(context.j.trace()) <<
"COMMAND:" << strCommand;
140 JLOG(context.j.trace()) <<
"REQUEST:" << context.params;
142 context.apiVersion, context.app.config().BETA_RPC_API, strCommand);
160template <
class Object,
class Method>
163 JsonContext& context,
169 auto& perfLog = context.app.getPerfLog();
173 perfLog.rpcStart(name, curId);
175 context.app.getJobQueue().makeLoadEvent(
jtGENERIC,
"cmd:" + name);
178 auto ret = method(context, result);
181 JLOG(context.j.debug())
182 <<
"RPC call " << name <<
" completed in "
183 << ((
end - start).
count() / 1000000000.0) <<
"seconds";
184 perfLog.rpcFinish(name, curId);
189 perfLog.rpcError(name, curId);
190 JLOG(context.j.info()) <<
"Caught throw: " << e.
what();
205 Handler const* handler =
nullptr;
206 if (
auto error = fillHandler(context, handler))
218 <<
"start command: " << handler->
name_
222 auto ret = callMethod(context, method, handler->
name_, result);
225 <<
"finish command: " << handler->
name_
233 auto ret = callMethod(context, method, handler->
name_, result);
249 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_