xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
rpc
handlers
server_info
Version.h
1
#pragma once
2
3
#include <xrpld/app/main/Application.h>
// IWYU pragma: keep
4
#include <xrpld/rpc/Context.h>
5
6
#include <xrpl/json/json_value.h>
7
#include <xrpl/protocol/ApiVersion.h>
8
9
#include <rpcspec/Errors.hpp>
10
11
#include <
cstdint
>
12
#include <expected>
13
#include <
functional
>
14
15
namespace
xrpl::rpc
{
16
20
class
VersionHandler
21
{
22
public
:
26
struct
Output
27
{
28
std::uint32_t
apiVersion
;
29
bool
betaEnabled
;
30
};
31
37
explicit
VersionHandler
(
JsonContext
& context) :
context_
(context)
38
{
39
}
40
46
[[nodiscard]] std::expected<Output, ::rpc::Status>
47
process
()
const
48
{
49
return
Output
{
50
.apiVersion =
context_
.get().apiVersion,
51
.betaEnabled =
context_
.get().app.config().betaRpcApi,
52
};
53
}
54
61
static
void
62
writeResult
(
json::Value
& obj,
Output
const
& output)
63
{
64
setVersion
(obj, output.
apiVersion
, output.
betaEnabled
);
65
}
66
67
private
:
68
std::reference_wrapper<JsonContext>
context_
;
69
};
70
71
}
// namespace xrpl::rpc
json::Value
Represents a JSON value.
Definition
json_value.h:121
xrpl::rpc::VersionHandler::process
std::expected< Output, ::rpc::Status > process() const
Process the request.
Definition
Version.h:47
xrpl::rpc::VersionHandler::VersionHandler
VersionHandler(JsonContext &context)
Construct a handler for a single request.
Definition
Version.h:37
xrpl::rpc::VersionHandler::writeResult
static void writeResult(json::Value &obj, Output const &output)
Write the output of process() into the response.
Definition
Version.h:62
xrpl::rpc::VersionHandler::context_
std::reference_wrapper< JsonContext > context_
Definition
Version.h:68
cstdint
functional
std::uint32_t
xrpl::rpc
The api_version numbers this server serves.
Definition
ApiVersion.h:26
xrpl::rpc::setVersion
void setVersion(json::Value &parent, unsigned int apiVersion, bool betaEnabled)
Definition
ApiVersion.h:61
std::reference_wrapper
xrpl::rpc::JsonContext
Definition
Context.h:41
xrpl::rpc::VersionHandler::Output
The data a version request produces, written out by writeResult().
Definition
Version.h:27
xrpl::rpc::VersionHandler::Output::apiVersion
std::uint32_t apiVersion
The API version of the request.
Definition
Version.h:28
xrpl::rpc::VersionHandler::Output::betaEnabled
bool betaEnabled
Whether the beta API version is enabled.
Definition
Version.h:29
Generated by
1.17.0