xrpld
Loading...
Searching...
No Matches
RPCLedgerHelpers.h
1#pragma once
2
3#include <xrpld/rpc/Context.h>
4#include <xrpld/rpc/detail/Tuning.h>
5
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/json/json_value.h>
8#include <xrpl/ledger/Ledger.h>
9#include <xrpl/server/NetworkOPs.h>
10
11#include <org/xrpl/rpc/v1/ledger.pb.h>
12#include <rpcspec/Errors.hpp>
13#include <rpcspec/Ledger.hpp>
14
15#include <cstdint>
16#include <expected>
17#include <memory>
18
19namespace xrpl {
20
21class ReadView;
22class Transaction;
23
24namespace rpc {
25
26struct JsonContext;
27
41template <class T>
42::rpc::Status
43getLedger(T& ledger, UInt256 const& ledgerHash, Context const& context);
44
59template <class T>
60::rpc::Status
61getLedger(T& ledger, uint32_t ledgerIndex, Context const& context);
62
77template <class T>
78::rpc::Status
79getLedger(T& ledger, ::rpc::spec::LedgerShortcut shortcut, Context const& context);
80
92template <class T>
93::rpc::Status
94getLedger(T& ledger, ::rpc::spec::LedgerSpecifier const& specifier, Context const& context);
95
106void
107injectLedgerFields(ReadView const& ledger, Context const& context, json::Value& result);
108
124json::Value
125lookupLedger(std::shared_ptr<ReadView const>&, JsonContext const&);
126
142::rpc::Status
143lookupLedger(std::shared_ptr<ReadView const>&, JsonContext const&, json::Value& result);
144
159template <class T, class R>
160::rpc::Status
161ledgerFromRequest(T& ledger, GRPCContext<R> const& context);
162
175template <class T>
176::rpc::Status
178 T& ledger,
179 org::xrpl::rpc::v1::LedgerSpecifier const& specifier,
180 Context const& context);
181
202std::expected<std::shared_ptr<Ledger const>, json::Value>
203getOrAcquireLedger(rpc::JsonContext const& context);
204
205} // namespace rpc
206
207} // namespace xrpl
A view into a ledger.
Definition ReadView.h:41
The api_version numbers this server serves.
Definition ApiVersion.h:26
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.
::rpc::Status ledgerFromRequest(T &ledger, GRPCContext< R > const &context)
Retrieves a ledger from a gRPC request context.
::rpc::Status ledgerFromSpecifier(T &ledger, org::xrpl::rpc::v1::LedgerSpecifier const &specifier, Context const &context)
Retrieves a ledger based on a LedgerSpecifier.
::rpc::Status getLedger(T &ledger, UInt256 const &ledgerHash, Context const &context)
Retrieves a ledger by its hash.
::rpc::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.
void injectLedgerFields(ReadView const &ledger, Context const &context, json::Value &result)
Writes the fields that identify a ledger into a result.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
BaseUInt< 256 > UInt256
Definition base_uint.h:581
The context of information needed to call an RPC.
Definition Context.h:27