|
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 (HashSet< AccountID > const &proposedAccounts, HashSet< AccountID > const &normalAccounts, std::size_t cap) |
| Enforce the cap and reserve a request's net-new accounts, atomically. | |
| bool | tryReserveMPTSubscriptions (HashSet< MPTID > const &mptIDs, std::size_t cap) |
| Enforce the cap and reserve a request's net-new MPT issuances, 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 |
| void | insertSubMPTInfo (MPTID const &mptID) |
| void | deleteSubMPTInfo (MPTID const &mptID) |
Public Attributes | |
| friend | Object |
Protected Attributes | |
| std::mutex | lock_ |
Private Types | |
| using | ScopedLock = std::scoped_lock<decltype(lock_)> |
Private Member Functions | |
| std::size_t | subscriptionCount (ScopedLock const &lock) const |
| The combined tally the per-connection cap is enforced against. | |
Static Private Member Functions | |
| static int | assignId () |
| static auto & | getCounter () noexcept |
Private Attributes | |
| Consumer | consumer_ |
| Source & | source_ |
| HashSet< AccountID > | realTimeSubscriptions_ |
| HashSet< AccountID > | normalSubscriptions_ |
| std::shared_ptr< InfoSubRequest > | request_ |
| std::uint64_t | seq_ |
| HashSet< AccountID > | accountHistorySubscriptions_ |
| HashSet< Book > | bookSubscriptions_ |
| HashSet< MPTID > | mptSubscriptions_ |
| 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& |
|
private |
| xrpl::InfoSub::InfoSub | ( | Source & | source | ) |
Definition at line 76 of file libxrpl/server/InfoSub.cpp.
Definition at line 80 of file libxrpl/server/InfoSub.cpp.
|
virtual |
Definition at line 85 of file libxrpl/server/InfoSub.cpp.
| resource::Consumer & xrpl::InfoSub::getConsumer | ( | ) |
Definition at line 160 of file libxrpl/server/InfoSub.cpp.
|
pure virtual |
Implemented in xrpl::RPCSubImp, and xrpl::WSInfoSub.
|
nodiscard |
Definition at line 166 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, account-history, and MPT issuance subscription sets. doSubscribe reads this to enforce the per-connection subscription cap before admitting more.
Definition at line 184 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 194 of file libxrpl/server/InfoSub.cpp.
|
nodiscard |
Enforce the cap and reserve a request's net-new MPT issuances, atomically.
The MPT analogue of tryReserveAccountSubscriptions: under one hold of lock_, count the net-new issuances, check the total against cap, and insert them only if it fits. All-or-nothing, so a rejected request records 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 issuances. The server-side map is populated afterwards by subMPT, whose re-insert is a no-op.
| mptIDs | The MPT issuance ids to reserve. |
| cap | The effective per-connection cap. |
Definition at line 214 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 271 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::onSendEmpty | ( | ) |
Definition at line 172 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::insertSubAccountInfo | ( | AccountID const & | account, |
| bool | rt ) |
Definition at line 227 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::deleteSubAccountInfo | ( | AccountID const & | account, |
| bool | rt ) |
Definition at line 242 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 278 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 285 of file libxrpl/server/InfoSub.cpp.
| bool xrpl::InfoSub::insertSubAccountHistory | ( | AccountID const & | account | ) |
Definition at line 257 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::deleteSubAccountHistory | ( | AccountID const & | account | ) |
Definition at line 264 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::clearRequest | ( | ) |
Definition at line 292 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::setRequest | ( | std::shared_ptr< InfoSubRequest > const & | req | ) |
Definition at line 298 of file libxrpl/server/InfoSub.cpp.
| std::shared_ptr< InfoSubRequest > const & xrpl::InfoSub::getRequest | ( | ) |
Definition at line 304 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::setApiVersion | ( | unsigned int | apiVersion | ) |
Definition at line 310 of file libxrpl/server/InfoSub.cpp.
|
nodiscardnoexcept |
Definition at line 316 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::insertSubMPTInfo | ( | MPTID const & | mptID | ) |
Definition at line 323 of file libxrpl/server/InfoSub.cpp.
| void xrpl::InfoSub::deleteSubMPTInfo | ( | MPTID const & | mptID | ) |
Definition at line 331 of file libxrpl/server/InfoSub.cpp.
|
nodiscardprivate |
The combined tally the per-connection cap is enforced against.
| lock | Proof that lock_ is held; unused otherwise. |
Definition at line 177 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.