21#include "data/BackendInterface.hpp"
23#include "rpc/common/Specs.hpp"
24#include "rpc/common/Types.hpp"
25#include "rpc/common/Validators.hpp"
27#include <boost/json/conversion.hpp>
28#include <boost/json/value.hpp>
29#include <xrpl/protocol/jss.h>
43 std::shared_ptr<BackendInterface> sharedPtrBackend_;
44 static constexpr auto kDATE_FORMAT =
"%Y-%m-%dT%TZ";
51 uint32_t ledgerIndex{};
52 std::string ledgerHash;
53 std::string closeTimeIso;
60 std::optional<std::string> date;
70 LedgerIndexHandler(std::shared_ptr<BackendInterface>
const& sharedPtrBackend) : sharedPtrBackend_(sharedPtrBackend)
81 spec([[maybe_unused]] uint32_t apiVersion)
83 static auto const kRPC_SPEC =
RpcSpec{
107 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output
const& output);
116 tag_invoke(boost::json::value_to_tag<Input>, boost::json::value
const& jv);
The ledger_index method fetches the lastest closed ledger before the given date.
Definition LedgerIndex.hpp:42
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition LedgerIndex.cpp:105
Result process(Input input, Context const &ctx) const
Process the LedgerIndex command.
Definition LedgerIndex.cpp:43
LedgerIndexHandler(std::shared_ptr< BackendInterface > const &sharedPtrBackend)
Construct a new LedgerIndexHandler object.
Definition LedgerIndex.hpp:70
static RpcSpecConstRef spec(uint32_t apiVersion)
Returns the API specification for the command.
Definition LedgerIndex.hpp:81
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:36
RpcSpec const & RpcSpecConstRef
An alias for a const reference to RpcSpec.
Definition Specs.hpp:145
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:81
Context of an RPC call.
Definition Types.hpp:118
A struct to hold the output data of the command.
Definition LedgerIndex.hpp:50
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:129
Represents a Specification of an entire RPC command.
Definition Specs.hpp:98
Validates that the type of the value is one of the given types.
Definition Validators.hpp:142