Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
LedgerEntry.hpp
1#pragma once
2
3#include "data/BackendInterface.hpp"
4#include "rpc/common/Types.hpp"
5
6#include <boost/json/object.hpp>
7#include <boost/json/value.hpp>
8#include <rpcspec/HandlerFor.hpp>
9#include <rpcspec/handlers/ledger_entry/Types.hpp>
10
11#include <cstdint>
12#include <memory>
13#include <optional>
14#include <string>
15#include <utility>
16
17namespace rpc {
18
25class LedgerEntryHandler : public rpc::spec::HandlerFor<rpc::spec::handlers::ledger_entry::Input> {
26 std::shared_ptr<BackendInterface> sharedPtrBackend_;
27
28public:
32 struct Output {
33 std::string index;
34 uint32_t ledgerIndex;
35 std::string ledgerHash;
36 std::optional<boost::json::object> node;
37 std::optional<std::string> nodeBinary;
38 std::optional<uint32_t> deletedLedgerIndex;
39 bool validated = true;
40 };
41
42 using Result = HandlerReturnType<Output>;
43
49 LedgerEntryHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
50 : sharedPtrBackend_(std::move(sharedPtrBackend))
51 {
52 }
53
61 [[nodiscard]] Result
62 process(Input const& input, Context const& ctx) const;
63
64private:
71 friend void
72 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
73};
74
75} // namespace rpc
LedgerEntryHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new LedgerEntryHandler object.
Definition LedgerEntry.hpp:49
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition LedgerEntry.cpp:478
Result process(Input const &input, Context const &ctx) const
Process the LedgerEntry command.
Definition LedgerEntry.cpp:419
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:17
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:61
Context of an RPC call.
Definition Types.hpp:98
A struct to hold the output data of the command.
Definition LedgerEntry.hpp:32
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:109