Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
Feature.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/value.hpp>
10
#include <rpcspec/handlers/feature/Types.hpp>
11
12
#include <cstdint>
13
#include <map>
14
#include <memory>
15
#include <string>
16
#include <utility>
17
18
namespace
rpc
{
19
23
class
FeatureHandler
:
public
rpc::HandlerFor
<rpc::spec::handlers::feature::Input> {
24
std::shared_ptr<BackendInterface> sharedPtrBackend_;
25
std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
26
27
public
:
31
struct
Output
{
35
struct
Feature
{
36
std::string name;
37
std::string key;
38
bool
supported =
false
;
39
bool
enabled =
false
;
40
};
41
42
std::map<std::string, Feature> features;
43
std::string ledgerHash;
44
uint32_t ledgerIndex{};
45
46
// when set to true, output will be inlined in `result` instead of wrapping as `features`
47
// inside of `result`.
48
bool
inlineResult =
false
;
49
50
// validated should be sent via framework
51
bool
validated =
true
;
52
};
53
54
using
Result
=
HandlerReturnType<Output>
;
55
62
FeatureHandler
(
63
std::shared_ptr<BackendInterface> sharedPtrBackend,
64
std::shared_ptr<data::AmendmentCenterInterface const>
const
& amendmentCenter
65
)
66
: sharedPtrBackend_(std::move(sharedPtrBackend)), amendmentCenter_(amendmentCenter)
67
{
68
}
69
77
[[nodiscard]]
Result
78
process
(
79
Input
const
& input,
80
Context
const
& ctx
81
)
const
;
// NOLINT(readability-convert-member-functions-to-static)
82
83
private
:
90
friend
void
91
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, Output
const
& output);
92
99
friend
void
100
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, Output::Feature
const
& feature);
101
};
102
103
}
// namespace rpc
rpc::FeatureHandler::process
Result process(Input const &input, Context const &ctx) const
Process the Feature command.
Definition
Feature.cpp:29
rpc::FeatureHandler::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
Feature.cpp:96
rpc::FeatureHandler::FeatureHandler
FeatureHandler(std::shared_ptr< BackendInterface > sharedPtrBackend, std::shared_ptr< data::AmendmentCenterInterface const > const &amendmentCenter)
Construct a new FeatureHandler object.
Definition
Feature.hpp:62
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:61
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:98
rpc::FeatureHandler::Output::Feature
Represents an amendment/feature.
Definition
Feature.hpp:35
rpc::FeatureHandler::Output
A struct to hold the output data of the command.
Definition
Feature.hpp:31
rpc::Result
Result type used to return responses or error statuses to the Webserver subsystem.
Definition
Types.hpp:109
src
rpc
handlers
Feature.hpp
Generated by
1.17.0