20 #include <ripple/rpc/handlers/Handlers.h>
21 #include <ripple/rpc/handlers/Version.h>
22 #include <ripple/rpc/impl/Handler.h>
23 #include <ripple/rpc/impl/RPCHelpers.h>
30 template <
typename Function>
31 Handler::Method<Json::Value>
32 byRef(Function
const& f)
34 return [f](JsonContext& context,
Json::Value& result) {
46 template <
class Object,
class HandlerImpl>
48 handle(JsonContext& context, Object&
object)
50 HandlerImpl handler(context);
52 auto status = handler.check();
56 handler.writeResult(
object);
60 Handler
const handlerArray[]{
64 {
"account_currencies",
80 {
"deposit_authorized",
119 {
"peer_reservations_add",
123 {
"peer_reservations_del",
127 {
"peer_reservations_list",
135 {
"submit_multisigned",
147 {
"validation_create",
152 {
"validator_list_sites",
167 template <std::
size_t N>
168 explicit HandlerTable(
const Handler (&entries)[N])
176 auto& innerTable = table_[versionToIndex(v)];
177 auto const& entry = entries[i];
178 assert(innerTable.find(entry.name_) == innerTable.end());
179 innerTable[entry.name_] = entry;
184 addHandler<LedgerHandler>(v);
185 addHandler<VersionHandler>(v);
190 static HandlerTable
const&
193 static HandlerTable
const handlerTable(handlerArray);
203 auto& innerTable = table_[versionToIndex(version)];
204 auto i = innerTable.find(name);
205 return i == innerTable.end() ? nullptr : &i->second;
212 for (
int index = 0; index < table_.size(); ++index)
214 for (
auto const& h : table_[index])
216 name_set.
insert(h.second.name_);
226 template <
class HandlerImpl>
228 addHandler(
unsigned version)
233 auto& innerTable = table_[versionToIndex(version)];
234 assert(innerTable.find(HandlerImpl::name()) == innerTable.end());
237 h.name_ = HandlerImpl::name();
238 h.valueMethod_ = &handle<Json::Value, HandlerImpl>;
239 h.role_ = HandlerImpl::role();
240 h.condition_ = HandlerImpl::condition();
242 innerTable[HandlerImpl::name()] = h;
246 versionToIndex(
unsigned version)
const
257 return HandlerTable::instance().getHandler(version, name);
263 return HandlerTable::instance().getHandlerNames();
Json::Value doFeature(RPC::JsonContext &context)
Json::Value doLedgerAccept(RPC::JsonContext &)
Json::Value doUnlList(RPC::JsonContext &)
Json::Value doGetCounts(RPC::JsonContext &context)
Json::Value doLedgerEntry(RPC::JsonContext &)
Json::Value doLedgerCurrent(RPC::JsonContext &)
Json::Value doAccountCurrencies(RPC::JsonContext &context)
Json::Value doValidationCreate(RPC::JsonContext &)
Json::Value doOwnerInfo(RPC::JsonContext &)
Json::Value doPathFind(RPC::JsonContext &)
Json::Value doDownloadShard(RPC::JsonContext &context)
RPC command that downloads and import shard archives.
Json::Value doAccountInfo(RPC::JsonContext &context)
Json::Value doRipplePathFind(RPC::JsonContext &)
Json::Value doSignFor(RPC::JsonContext &)
Json::Value doAccountObjects(RPC::JsonContext &context)
General RPC command that can retrieve objects in the account root.
constexpr unsigned int APINumberVersionSupported
Json::Value doValidators(RPC::JsonContext &)
Json::Value doValidatorListSites(RPC::JsonContext &)
Json::Value doChannelVerify(RPC::JsonContext &)
@ NEEDS_NETWORK_CONNECTION
Json::Value doPrint(RPC::JsonContext &)
Json::Value doGatewayBalances(RPC::JsonContext &context)
Json::Value doManifest(RPC::JsonContext &)
Json::Value doPeers(RPC::JsonContext &)
Json::Value doSubmitMultiSigned(RPC::JsonContext &)
Json::Value doCrawlShards(RPC::JsonContext &context)
RPC command that reports stored shards by nodes.
Json::Value doTxHistory(RPC::JsonContext &)
constexpr unsigned int ApiMinimumSupportedVersion
Json::Value doLogLevel(RPC::JsonContext &)
Json::Value doSubmit(RPC::JsonContext &)
@ objectValue
object value (collection of name/value pairs).
Json::Value doPing(RPC::JsonContext &)
Json::Value doLedgerRequest(RPC::JsonContext &)
Json::Value doChannelAuthorize(RPC::JsonContext &)
Json::Value doRandom(RPC::JsonContext &)
Json::Value doValidatorInfo(RPC::JsonContext &)
Json::Value doStop(RPC::JsonContext &)
Json::Value doWalletPropose(RPC::JsonContext &)
constexpr unsigned int ApiMaximumSupportedVersion
Json::Value doCanDelete(RPC::JsonContext &context)
Json::Value doConsensusInfo(RPC::JsonContext &context)
Json::Value doLedgerData(RPC::JsonContext &)
Json::Value doAccountOffers(RPC::JsonContext &context)
Json::Value doLogRotate(RPC::JsonContext &)
Json::Value doNoRippleCheck(RPC::JsonContext &)
Json::Value doLedgerClosed(RPC::JsonContext &)
Json::Value doBookOffers(RPC::JsonContext &context)
Json::Value doPeerReservationsList(RPC::JsonContext &)
Status
Return codes from Backend operations.
Json::Value doTransactionEntry(RPC::JsonContext &)
Json::Value doUnsubscribe(RPC::JsonContext &)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Json::Value doBlackList(RPC::JsonContext &context)
Json::Value doAccountTxJson(RPC::JsonContext &context)
Json::Value doSign(RPC::JsonContext &)
Json::Value doPeerReservationsDel(RPC::JsonContext &)
Json::Value doTxJson(RPC::JsonContext &)
Json::Value makeObjectValue(Value const &value, Json::StaticString const &field=jss::message)
Return a Json::objectValue with a single entry.
Json::Value doAccountChannels(RPC::JsonContext &context)
Json::Value doServerInfo(RPC::JsonContext &)
Json::Value doLedgerHeader(RPC::JsonContext &)
Json::Value doFetchInfo(RPC::JsonContext &context)
Json::Value doServerState(RPC::JsonContext &)
Json::Value doConnect(RPC::JsonContext &context)
Json::Value doLedgerCleaner(RPC::JsonContext &)
std::vector< char const * > getHandlerNames()
Return names of all methods.
Json::Value doDepositAuthorized(RPC::JsonContext &context)
Handler const * getHandler(unsigned version, std::string const &name)
Json::Value doPeerReservationsAdd(RPC::JsonContext &)
Json::Value doAccountLines(RPC::JsonContext &context)
Json::Value doFee(RPC::JsonContext &context)
Json::Value doSubscribe(RPC::JsonContext &)