Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
LedgerFeed.hpp
1#pragma once
2
3#include "data/BackendInterface.hpp"
4#include "feed/Types.hpp"
5#include "feed/impl/SingleFeedBase.hpp"
6#include "util/async/AnyExecutionContext.hpp"
7
8#include <boost/asio/io_context.hpp>
9#include <boost/asio/spawn.hpp>
10#include <boost/json/object.hpp>
11#include <boost/json/serialize.hpp>
12#include <xrpl/protocol/Fees.h>
13#include <xrpl/protocol/LedgerHeader.h>
14
15#include <cstdint>
16#include <memory>
17#include <string>
18
19namespace feed::impl {
20
28class LedgerFeed : public SingleFeedBase {
29public:
35 : SingleFeedBase(executionCtx, "ledger")
36 {
37 }
38
47 boost::json::object
48 sub(boost::asio::yield_context yield,
49 std::shared_ptr<data::BackendInterface const> const& backend,
50 SubscriberSharedPtr const& subscriber,
51 uint32_t networkID);
52
61 void
62 pub(ripple::LedgerHeader const& lgrInfo,
63 ripple::Fees const& fees,
64 std::string const& ledgerRange,
65 uint32_t txnCount,
66 uint32_t networkID);
67
68private:
69 static boost::json::object
70 makeLedgerPubMessage(
71 ripple::LedgerHeader const& lgrInfo,
72 ripple::Fees const& fees,
73 std::string const& ledgerRange,
74 uint32_t txnCount,
75 uint32_t networkID
76 );
77};
78} // namespace feed::impl
void pub(ripple::LedgerHeader const &lgrInfo, ripple::Fees const &fees, std::string const &ledgerRange, uint32_t txnCount, uint32_t networkID)
Publishes the ledger feed.
Definition LedgerFeed.cpp:77
LedgerFeed(util::async::AnyExecutionContext &executionCtx)
Construct a new Ledger Feed object.
Definition LedgerFeed.hpp:34
boost::json::object sub(boost::asio::yield_context yield, std::shared_ptr< data::BackendInterface const > const &backend, SubscriberSharedPtr const &subscriber, uint32_t networkID)
Subscribe the ledger feed.
Definition LedgerFeed.cpp:47
SingleFeedBase(util::async::AnyExecutionContext &executionCtx, std::string const &name)
Construct a new Single Feed Base object.
Definition SingleFeedBase.cpp:16
A type-erased execution context.
Definition AnyExecutionContext.hpp:22