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/perflog/PerfLog.h>
28#include <xrpld/rpc/Context.h>
29#include <xrpld/rpc/InfoSub.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>
35#include <xrpl/basics/Log.h>
36#include <xrpl/json/to_string.h>
37#include <xrpl/protocol/ErrorCodes.h>
38#include <xrpl/protocol/jss.h>
39#include <xrpl/resource/Fees.h>
130fillHandler(JsonContext& context, Handler
const*& result)
135 int const jobCount = context.app.getJobQueue().getJobCountGE(
jtCLIENT);
138 JLOG(context.j.debug()) <<
"Too busy for command: " << jobCount;
143 if (!context.params.isMember(jss::command) &&
144 !context.params.isMember(jss::method))
146 if (context.params.isMember(jss::command) &&
147 context.params.isMember(jss::method))
149 if (context.params[jss::command].asString() !=
150 context.params[jss::method].asString())
154 std::string strCommand = context.params.isMember(jss::command)
155 ? context.params[jss::command].asString()
156 : context.params[jss::method].asString();
158 JLOG(context.j.trace()) <<
"COMMAND:" << strCommand;
159 JLOG(context.j.trace()) <<
"REQUEST:" << context.params;
161 context.apiVersion, context.app.config().BETA_RPC_API, strCommand);
179template <
class Object,
class Method>
182 JsonContext& context,
188 auto& perfLog = context.app.getPerfLog();
192 perfLog.rpcStart(name, curId);
194 context.app.getJobQueue().makeLoadEvent(
jtGENERIC,
"cmd:" + name);
197 auto ret = method(context, result);
200 JLOG(context.j.debug())
201 <<
"RPC call " << name <<
" completed in "
202 << ((
end - start).
count() / 1000000000.0) <<
"seconds";
203 perfLog.rpcFinish(name, curId);
208 perfLog.rpcError(name, curId);
209 JLOG(context.j.info()) <<
"Caught throw: " << e.
what();
224 Handler const* handler =
nullptr;
225 if (
auto error = fillHandler(context, handler))
237 <<
"start command: " << handler->
name_
241 auto ret = callMethod(context, method, handler->
name_, result);
244 <<
"finish command: " << handler->
name_
252 auto ret = callMethod(context, method, handler->
name_, result);
268 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_