20 #include <ripple/basics/contract.h>
21 #include <ripple/rpc/handlers/Handlers.h>
22 #include <ripple/rpc/handlers/Version.h>
23 #include <ripple/rpc/impl/Handler.h>
24 #include <ripple/rpc/impl/RPCHelpers.h>
33 template <
typename Function>
34 Handler::Method<Json::Value>
35 byRef(Function
const& f)
37 return [f](JsonContext& context,
Json::Value& result) {
49 template <
class Object,
class HandlerImpl>
51 handle(JsonContext& context, Object&
object)
54 context.apiVersion >= HandlerImpl::minApiVer &&
55 context.apiVersion <= HandlerImpl::maxApiVer);
56 HandlerImpl handler(context);
58 auto status = handler.check();
62 handler.writeResult(
object);
66 template <
typename HandlerImpl>
72 &handle<Json::Value, HandlerImpl>,
74 HandlerImpl::condition,
75 HandlerImpl::minApiVer,
76 HandlerImpl::maxApiVer};
79 Handler
const handlerArray[]{
83 {
"account_currencies",
103 {
"deposit_authorized",
108 #ifdef RIPPLED_REPORTING
149 {
"peer_reservations_add",
153 {
"peer_reservations_del",
157 {
"peer_reservations_list",
162 {
"server_definitions",
172 {
"submit_multisigned",
181 {
"validation_create",
186 {
"validator_list_sites",
205 overlappingApiVersion(
210 assert(minVer <= maxVer);
216 [minVer, maxVer](
auto const& item) {
217 return item.second.minApiVer_ <= maxVer &&
218 item.second.maxApiVer_ >= minVer;
222 template <std::
size_t N>
223 explicit HandlerTable(
const Handler (&entries)[N])
225 for (
auto const& entry : entries)
227 if (overlappingApiVersion(
233 " overlaps with an existing handler");
235 table_.
insert({entry.name_, entry});
239 addHandler<LedgerHandler>();
240 addHandler<VersionHandler>();
244 static HandlerTable
const&
247 static HandlerTable
const handlerTable(handlerArray);
251 [[nodiscard]] Handler
const*
262 range.first,
range.second, [version](
auto const& entry) {
263 return entry.second.minApiVer_ <= version &&
264 version <= entry.second.maxApiVer_;
267 return i ==
range.second ? nullptr : &i->second;
274 for (
auto const& i : table_)
275 ret.
insert(i.second.name_);
281 handler_table_t table_;
283 template <
class HandlerImpl>
287 static_assert(HandlerImpl::minApiVer <= HandlerImpl::maxApiVer);
292 if (overlappingApiVersion(
294 HandlerImpl::minApiVer,
295 HandlerImpl::maxApiVer))
298 " overlaps with an existing handler");
300 table_.
insert({HandlerImpl::name, handlerFrom<HandlerImpl>()});
309 return HandlerTable::instance().getHandler(version, betaEnabled, name);
315 return HandlerTable::instance().getHandlerNames();
Json::Value doAccountNFTs(RPC::JsonContext &context)
General RPC command that can retrieve objects in the account root.
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 &)
Handler const * getHandler(unsigned version, bool betaEnabled, std::string const &name)
std::set< char const * > getHandlerNames()
Return names of all methods.
Json::Value doAccountObjects(RPC::JsonContext &context)
Json::Value doServerDefinitions(RPC::JsonContext &)
Json::Value doValidators(RPC::JsonContext &)
Json::Value doValidatorListSites(RPC::JsonContext &)
Json::Value doTxReduceRelay(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 &)
constexpr unsigned int apiBetaVersion
Json::Value doNFTBuyOffers(RPC::JsonContext &)
Json::Value doCrawlShards(RPC::JsonContext &context)
RPC command that reports stored shards by nodes.
Json::Value doTxHistory(RPC::JsonContext &)
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 doNFTSellOffers(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 &)
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 &)
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Json::Value doBookOffers(RPC::JsonContext &context)
Json::Value doPeerReservationsList(RPC::JsonContext &)
Json::Value doAMMInfo(RPC::JsonContext &context)
Status
Return codes from Backend operations.
Json::Value doTransactionEntry(RPC::JsonContext &)
Json::Value doUnsubscribe(RPC::JsonContext &)
constexpr unsigned int apiMinimumSupportedVersion
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr unsigned int apiMaximumValidVersion
Json::Value doBlackList(RPC::JsonContext &context)
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
Json::Value doAccountTxJson(RPC::JsonContext &context)
Json::Value doSign(RPC::JsonContext &)
Json::Value doPeerReservationsDel(RPC::JsonContext &)
Json::Value doTxJson(RPC::JsonContext &)
constexpr unsigned int apiMaximumSupportedVersion
Json::Value doNodeToShard(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 &)
Json::Value doDepositAuthorized(RPC::JsonContext &context)
Json::Value doPeerReservationsAdd(RPC::JsonContext &)
Json::Value doBookChanges(RPC::JsonContext &context)
Json::Value doAccountLines(RPC::JsonContext &context)
Json::Value doFee(RPC::JsonContext &context)
Json::Value doSubscribe(RPC::JsonContext &)