xrpld
Loading...
Searching...
No Matches
RPCLedgerHelpers.h
1#pragma once
2
3#include <xrpld/app/misc/TxQ.h>
4#include <xrpld/rpc/Context.h>
5#include <xrpld/rpc/Status.h>
6#include <xrpld/rpc/detail/Tuning.h>
7
8#include <xrpl/ledger/Ledger.h>
9#include <xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.pb.h>
10#include <xrpl/protocol/LedgerShortcut.h>
11#include <xrpl/server/NetworkOPs.h>
12
13#include <expected>
14#include <optional>
15
16namespace xrpl {
17
18class ReadView;
19class Transaction;
20
21namespace RPC {
22
23struct JsonContext;
24
38template <class T>
40getLedger(T& ledger, uint256 const& ledgerHash, Context const& context);
41
56template <class T>
58getLedger(T& ledger, uint32_t ledgerIndex, Context const& context);
59
74template <class T>
76getLedger(T& ledger, LedgerShortcut shortcut, Context const& context);
77
93json::Value
94lookupLedger(std::shared_ptr<ReadView const>&, JsonContext const&);
95
111Status
112lookupLedger(std::shared_ptr<ReadView const>&, JsonContext const&, json::Value& result);
113
128template <class T, class R>
129Status
130ledgerFromRequest(T& ledger, GRPCContext<R> const& context);
131
144template <class T>
145Status
147 T& ledger,
148 org::xrpl::rpc::v1::LedgerSpecifier const& specifier,
149 Context const& context);
150
171std::expected<std::shared_ptr<Ledger const>, json::Value>
172getOrAcquireLedger(RPC::JsonContext const& context);
173
174} // namespace RPC
175
176} // namespace xrpl
A view into a ledger.
Definition ReadView.h:31
API version numbers used in later API versions.
Definition ApiVersion.h:35
std::expected< std::shared_ptr< Ledger const >, json::Value > getOrAcquireLedger(RPC::JsonContext const &context)
Retrieves or acquires a ledger based on the parameters provided in the given JsonContext.
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext const &context, json::Value &result)
Looks up a ledger from a request and fills a json::Value with ledger data.
Status ledgerFromSpecifier(T &ledger, org::xrpl::rpc::v1::LedgerSpecifier const &specifier, Context const &context)
Retrieves a ledger based on a LedgerSpecifier.
Status ledgerFromRequest(T &ledger, GRPCContext< R > const &context)
Retrieves a ledger from a gRPC request context.
Status getLedger(T &ledger, uint256 const &ledgerHash, Context const &context)
Retrieves a ledger by its hash.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
LedgerShortcut
Enumeration of ledger shortcuts for specifying which ledger to use.
BaseUInt< 256 > uint256
Definition base_uint.h:562
The context of information needed to call an RPC.
Definition Context.h:19
Status represents the results of an operation that might fail.
Definition Status.h:19