|
xrpld
|
Manages a client's subscription to data feeds. More...
#include <InfoSub.h>


Classes | |
| class | Source |
| Abstracts the source of subscription data. More... | |
Public Types | |
| using | pointer = std::shared_ptr<InfoSub> |
| using | wptr = std::weak_ptr<InfoSub> |
| using | ref = std::shared_ptr<InfoSub> const& |
| using | Consumer = resource::Consumer |
Public Member Functions | |
| InfoSub (Source &source) | |
| InfoSub (Source &source, Consumer consumer) | |
| virtual | ~InfoSub () |
| Consumer & | getConsumer () |
| virtual void | send (json::Value const &jvObj, bool broadcast)=0 |
| std::uint64_t | getSeq () const |
| std::size_t | totalSubscriptionCount () const |
| Return the number of subscriptions currently tracked on this connection. | |
| bool | tryReserveAccountSubscriptions (hash_set< AccountID > const &proposedAccounts, hash_set< AccountID > const &normalAccounts, std::size_t cap) |
| Enforce the cap and reserve a request's net-new accounts, atomically. | |
| bool | hasAccountHistorySubscription (AccountID const &account) const |
Whether this connection already tracks an account-history for account. | |
| void | onSendEmpty () |
| void | insertSubAccountInfo (AccountID const &account, bool rt) |
| void | deleteSubAccountInfo (AccountID const &account, bool rt) |
| void | insertBookSubscription (Book const &book) |
Record that this subscriber is following book. | |
| void | deleteBookSubscription (Book const &book) |
Stop tracking book for this subscriber. | |
| bool | insertSubAccountHistory (AccountID const &account) |
| void | deleteSubAccountHistory (AccountID const &account) |
| void | clearRequest () |
| void | setRequest (std::shared_ptr< InfoSubRequest > const &req) |
| std::shared_ptr< InfoSubRequest > const & | getRequest () |
| void | setApiVersion (unsigned int apiVersion) |
| unsigned int | getApiVersion () const noexcept |
Public Attributes | |
| friend | Object |
Protected Attributes | |
| std::mutex | lock_ |
Static Private Member Functions | |
| static int | assignId () |
| static auto & | getCounter () noexcept |
Private Attributes | |
| Consumer | consumer_ |
| Source & | source_ |
| hash_set< AccountID > | realTimeSubscriptions_ |
| hash_set< AccountID > | normalSubscriptions_ |
| std::shared_ptr< InfoSubRequest > | request_ |
| std::uint64_t | seq_ |
| hash_set< AccountID > | accountHistorySubscriptions_ |
| hash_set< Book > | bookSubscriptions_ |
| unsigned int | apiVersion_ = 0 |
Manages a client's subscription to data feeds.
An InfoSub holds a non-owning reference to its Source (typically the process-wide NetworkOPsImp). The destructor reaches back into the Source to remove this subscriber from every server-side subscription map.
| using xrpl::InfoSub::pointer = std::shared_ptr<InfoSub> |
| using xrpl::InfoSub::wptr = std::weak_ptr<InfoSub> |
| using xrpl::InfoSub::ref = std::shared_ptr<InfoSub> const& |
| xrpl::InfoSub::InfoSub | ( | Source & | source | ) |
Definition at line 58 of file libxrpl/server/InfoSub.cpp.
Definition at line 62 of file libxrpl/server/InfoSub.cpp.
|
virtual |
Definition at line 67 of file libxrpl/server/InfoSub.cpp.
| resource::Consumer & xrpl::InfoSub::getConsumer | ( | ) |
Definition at line 132 of file libxrpl/server/InfoSub.cpp.
|
pure virtual |
Implemented in xrpl::RPCSubImp, and xrpl::WSInfoSub.
|
nodiscard |
Definition at line 138 of file libxrpl/server/InfoSub.cpp.
|
nodiscard |
Return the number of subscriptions currently tracked on this connection.
The combined size of the per-connection account, real-time account, and account-history subscription sets. doSubscribe reads this to enforce the per-connection subscription cap before admitting more.
Definition at line 149 of file libxrpl/server/InfoSub.cpp.
|
nodiscard |
Enforce the cap and reserve a request's net-new accounts, atomically.
Under one hold of lock_: count the net-new entries in the two sets, check the total against cap, and insert them only if it fits. All-or-nothing. Doing check and insert together stops two concurrent requests sharing an InfoSub (the admin subscribe-by-url path) from both passing the check before either records its accounts. The server-side maps are populated afterwards by subAccount, whose re-insert is a no-op.
| proposedAccounts | Real-time (accounts_proposed) ids to reserve. |
| normalAccounts | Normal (accounts) ids to reserve. |
| cap | The effective per-connection cap. |
Definition at line 161 of file libxrpl/server/InfoSub.cpp.
|
nodiscard |
Whether this connection already tracks an account-history for account.
doSubscribe reads this to charge the cap for an account_history_tx_stream only when it is net-new, matching the account branches.
| account | The account an account_history_tx_stream would add. |
account is already in the account-history set. Definition at line 240 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::onSendEmpty | ( | ) |
Definition at line 144 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::insertSubAccountInfo | ( | AccountID const & | account, |
| bool | rt ) |
Definition at line 196 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::deleteSubAccountInfo | ( | AccountID const & | account, |
| bool | rt ) |
Definition at line 211 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::insertBookSubscription | ( | Book const & | book | ) |
Record that this subscriber is following book.
Called by NetworkOPsImp::subBook so that ~InfoSub() can issue a matching unsubBook for every book this subscriber is tracking, keeping per-subscriber state symmetric with the server-side map.
| book | The order book this subscriber has just subscribed to. |
Definition at line 247 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::deleteBookSubscription | ( | Book const & | book | ) |
Stop tracking book for this subscriber.
Called by the unsubscribe RPC handler so that the book is not re-unsubscribed by ~InfoSub(). Pairs with insertBookSubscription.
| book | The order book to forget. |
book was not previously inserted. Definition at line 254 of file libxrpl/server/InfoSub.cpp.
| bool xrpl::InfoSub::insertSubAccountHistory | ( | AccountID const & | account | ) |
Definition at line 226 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::deleteSubAccountHistory | ( | AccountID const & | account | ) |
Definition at line 233 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::clearRequest | ( | ) |
Definition at line 261 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::setRequest | ( | std::shared_ptr< InfoSubRequest > const & | req | ) |
Definition at line 267 of file libxrpl/server/InfoSub.cpp.
| std::shared_ptr< InfoSubRequest > const & xrpl::InfoSub::getRequest | ( | ) |
Definition at line 273 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::setApiVersion | ( | unsigned int | apiVersion | ) |
Definition at line 279 of file libxrpl/server/InfoSub.cpp.
|
nodiscardnoexcept |
Definition at line 285 of file libxrpl/server/InfoSub.cpp.
|
staticprivatenoexceptinherited |
Definition at line 113 of file CountedObject.h.
|
mutableprotected |
|
private |
|
private |
|
inherited |
Definition at line 138 of file CountedObject.h.