Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
BookOffers.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/array.hpp>
9#include <boost/json/conversion.hpp>
10#include <boost/json/object.hpp>
11#include <boost/json/value.hpp>
12#include <rpcspec/handlers/book_offers/Types.hpp>
13
14#include <cstdint>
15#include <memory>
16#include <string>
17#include <utility>
18
19namespace rpc {
20
27class BookOffersHandler : public rpc::HandlerFor<rpc::spec::handlers::book_offers::Input> {
28 std::shared_ptr<BackendInterface> sharedPtrBackend_;
29 std::shared_ptr<data::AmendmentCenterInterface const> amendmentCenter_;
30
31public:
32 static constexpr auto kLimitMin = rpc::spec::handlers::book_offers::kLimitMin;
33 static constexpr auto kLimitMax = rpc::spec::handlers::book_offers::kLimitMax;
34 static constexpr auto kLimitDefault = rpc::spec::handlers::book_offers::kLimitDefault;
35
39 struct Output {
40 std::string ledgerHash;
41 uint32_t ledgerIndex;
42 boost::json::array offers;
43 bool validated = true;
44 };
45
46 using Result = HandlerReturnType<Output>;
47
55 std::shared_ptr<BackendInterface> sharedPtrBackend,
56 std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter
57 )
58 : sharedPtrBackend_(std::move(sharedPtrBackend)), amendmentCenter_{amendmentCenter}
59 {
60 }
61
69 [[nodiscard]] Result
70 process(Input const& input, Context const& ctx) const;
71
72private:
79 friend void
80 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
81};
82} // namespace rpc
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition BookOffers.cpp:68
BookOffersHandler(std::shared_ptr< BackendInterface > sharedPtrBackend, std::shared_ptr< data::AmendmentCenterInterface const > const &amendmentCenter)
Construct a new BookOffersHandler object.
Definition BookOffers.hpp:54
Result process(Input const &input, Context const &ctx) const
Process the BookOffers command.
Definition BookOffers.cpp:23
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
spec::HandlerFor< InputT, boost::json::value > HandlerFor
The spec-driven base every typed handler inherits.
Definition SpecBackend.hpp:24
A struct to hold the output data of the command.
Definition BookOffers.hpp:39
Context of an RPC call.
Definition Types.hpp:98
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:109