22#include "data/AmendmentCenterInterface.hpp"
23#include "data/BackendInterface.hpp"
24#include "data/Types.hpp"
25#include "feed/Types.hpp"
26#include "feed/impl/TrackableSignal.hpp"
27#include "feed/impl/TrackableSignalMap.hpp"
28#include "feed/impl/Util.hpp"
29#include "util/async/AnyExecutionContext.hpp"
30#include "util/async/AnyStrand.hpp"
31#include "util/log/Logger.hpp"
32#include "util/prometheus/Gauge.hpp"
34#include <boost/asio/io_context.hpp>
35#include <boost/asio/strand.hpp>
37#include <xrpl/protocol/AccountID.h>
38#include <xrpl/protocol/Book.h>
39#include <xrpl/protocol/LedgerHeader.h>
46#include <unordered_set>
52 using AllVersionTransactionsType = std::array<std::shared_ptr<std::string>, 2>;
54 struct TransactionSlot {
55 std::reference_wrapper<TransactionFeed>
feed;
56 std::weak_ptr<Subscriber> subscriptionContextWeakPtr;
59 :
feed(
feed), subscriptionContextWeakPtr(connection)
64 operator()(AllVersionTransactionsType
const& allVersionMsgs)
const;
70 std::reference_wrapper<util::prometheus::GaugeInt> subAllCount_;
71 std::reference_wrapper<util::prometheus::GaugeInt> subAccountCount_;
72 std::reference_wrapper<util::prometheus::GaugeInt> subBookCount_;
82 std::unordered_set<SubscriberPtr>
91 : strand_(executionCtx.makeStrand())
92 , subAllCount_(getSubscriptionsGaugeInt(
"tx"))
93 , subAccountCount_(getSubscriptionsGaugeInt(
"account"))
94 , subBookCount_(getSubscriptionsGaugeInt(
"book"))
108 sub(SubscriberSharedPtr
const& subscriber);
116 sub(ripple::AccountID
const& account, SubscriberSharedPtr
const& subscriber);
124 sub(ripple::Book
const& book, SubscriberSharedPtr
const& subscriber);
131 subProposed(SubscriberSharedPtr
const& subscriber);
140 subProposed(ripple::AccountID
const& account, SubscriberSharedPtr
const& subscriber);
147 unsub(SubscriberSharedPtr
const& subscriber);
155 unsub(ripple::AccountID
const& account, SubscriberSharedPtr
const& subscriber);
170 unsubProposed(ripple::AccountID
const& account, SubscriberSharedPtr
const& subscriber);
178 unsub(ripple::Book
const& book, SubscriberSharedPtr
const& subscriber);
188 ripple::LedgerHeader
const& lgrInfo,
189 std::shared_ptr<data::BackendInterface const>
const& backend,
190 std::shared_ptr<data::AmendmentCenterInterface const>
const& amendmentCenter);
215 unsubInternal(ripple::AccountID
const& account,
SubscriberPtr subscriber);
221 unsubProposedInternal(ripple::AccountID
const& account,
SubscriberPtr subscriber);
224 unsubInternal(ripple::Book
const& book,
SubscriberPtr subscriber);
Class to manage a map of key and its associative signal.
Definition TrackableSignalMap.hpp:49
A thread-safe class to manage a signal and its tracking connections.
Definition TrackableSignal.hpp:44
Definition TransactionFeed.hpp:50
void unsub(SubscriberSharedPtr const &subscriber)
Unsubscribe to the transaction feed.
Definition TransactionFeed.cpp:127
void sub(SubscriberSharedPtr const &subscriber)
Subscribe to the transaction feed.
Definition TransactionFeed.cpp:73
void unsubProposed(SubscriberSharedPtr const &subscriber)
Unsubscribe to the transaction feed for proposed transaction stream.
Definition TransactionFeed.cpp:139
std::uint64_t bookSubCount() const
Get the number of books subscribers.
Definition TransactionFeed.cpp:169
void pub(data::TransactionAndMetadata const &txMeta, ripple::LedgerHeader const &lgrInfo, std::shared_ptr< data::BackendInterface const > const &backend, std::shared_ptr< data::AmendmentCenterInterface const > const &amendmentCenter)
Publishes the transaction feed.
Definition TransactionFeed.cpp:175
std::uint64_t transactionSubCount() const
Get the number of subscribers of the transaction feed.
Definition TransactionFeed.cpp:157
TransactionFeed(TransactionFeed &&)=delete
Move constructor is deleted because TransactionSlot takes TransactionFeed by reference.
std::uint64_t accountSubCount() const
Get the number of accounts subscribers.
Definition TransactionFeed.cpp:163
TransactionFeed(util::async::AnyExecutionContext &executionCtx)
Construct a new Transaction Feed object.
Definition TransactionFeed.hpp:90
void subProposed(SubscriberSharedPtr const &subscriber)
Subscribe to the transaction feed for proposed transaction stream.
Definition TransactionFeed.cpp:95
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:111
A type-erased execution context.
Definition AnyExecutionContext.hpp:41
A type-erased execution context.
Definition AnyStrand.hpp:40
An interface to provide connection functionality for subscriptions.
Definition SubscriptionContextInterface.hpp:39
This namespace implements everything related to subscriptions.
Definition BookChangesFeed.hpp:33