Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Ledger.hpp
1
#pragma once
2
3
#include "data/AmendmentCenterInterface.hpp"
4
#include "data/BackendInterface.hpp"
5
#include "rpc/common/SpecBackend.hpp"
6
#include "rpc/common/Types.hpp"
7
8
#include <boost/json/conversion.hpp>
9
#include <boost/json/object.hpp>
10
#include <boost/json/value.hpp>
11
#include <rpcspec/handlers/ledger/Types.hpp>
12
13
#include <cstdint>
14
#include <memory>
15
#include <string>
16
#include <utility>
17
18
namespace
rpc
{
19
25
class
LedgerHandler
:
public
rpc::HandlerFor
<rpc::spec::handlers::ledger::Input> {
26
std::shared_ptr<BackendInterface> sharedPtrBackend_;
27
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
28
29
public
:
33
struct
Output
{
34
uint32_t
ledgerIndex
{};
35
std::string
ledgerHash
;
36
// TODO: use better type
37
boost::json::object
header
;
38
bool
validated
=
true
;
39
};
40
44
using
Result
=
HandlerReturnType<Output>
;
45
52
LedgerHandler
(
53
std::shared_ptr<BackendInterface> sharedPtrBackend,
54
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter
55
)
56
: sharedPtrBackend_(std::move(sharedPtrBackend))
57
, amendmentCenter_(std::move(amendmentCenter))
58
{
59
}
60
68
[[nodiscard]]
Result
69
process
(Input
const
& input,
Context
const
& ctx)
const
;
70
71
private
:
78
friend
void
79
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, Output
const
& output);
80
};
81
}
// namespace rpc
rpc::LedgerHandler::Result
HandlerReturnType< Output > Result
The result type of the command: either the Output or an error status.
Definition
Ledger.hpp:44
rpc::LedgerHandler::LedgerHandler
LedgerHandler(std::shared_ptr< BackendInterface > sharedPtrBackend, std::shared_ptr< data::AmendmentCenterInterface const > amendmentCenter)
Construct a new LedgerHandler object.
Definition
Ledger.hpp:52
rpc::LedgerHandler::tag_invoke
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition
Ledger.cpp:179
rpc::LedgerHandler::process
Result process(Input const &input, Context const &ctx) const
Process the Ledger command.
Definition
Ledger.cpp:32
rpc
This namespace contains all the RPC logic and handlers.
Definition
AMMHelpers.cpp:17
rpc::HandlerReturnType
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition
Types.hpp:63
rpc::HandlerFor
spec::HandlerFor< InputT, boost::json::value > HandlerFor
The spec-driven base every typed handler inherits.
Definition
SpecBackend.hpp:24
rpc::Context
Context of an RPC call.
Definition
Types.hpp:102
rpc::LedgerHandler::Output
A struct to hold the output data of the command.
Definition
Ledger.hpp:33
rpc::LedgerHandler::Output::ledgerHash
std::string ledgerHash
Hash of the requested ledger.
Definition
Ledger.hpp:35
rpc::LedgerHandler::Output::validated
bool validated
Whether the ledger is validated.
Definition
Ledger.hpp:38
rpc::LedgerHandler::Output::ledgerIndex
uint32_t ledgerIndex
Sequence of the requested ledger.
Definition
Ledger.hpp:34
rpc::LedgerHandler::Output::header
boost::json::object header
Ledger header plus any requested transactions and diff.
Definition
Ledger.hpp:37
rpc::Result
Result type used to return responses or error statuses to the Webserver subsystem.
Definition
Types.hpp:132
src
rpc
handlers
Ledger.hpp
Generated by
1.17.0