1#include <xrpl/server/InfoSub.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/beast/utility/instrumentation.h>
6#include <xrpl/protocol/AccountID.h>
7#include <xrpl/protocol/Book.h>
8#include <xrpl/resource/Consumer.h>
29safeUnsub(std::uint64_t seq, F&& f, beast::Journal j)
noexcept
35 catch (std::exception
const& e)
37 JLOG(j.warn()) <<
"~InfoSub[seq=" << seq <<
"]: cleanup step failed: " << e.
what();
41 JLOG(j.warn()) <<
"~InfoSub[seq=" << seq <<
"]: cleanup step failed: unknown exception";
76 auto const& j =
source_.journal();
122 source_.scheduleAccountCleanup(
173 for (
auto const& account : requested)
175 if (!existing.contains(account))
287 XRPL_ASSERT(
apiVersion_ > 0,
"xrpl::InfoSub::getApiVersion : valid API version");
Abstracts the source of subscription data.
void setRequest(std::shared_ptr< InfoSubRequest > const &req)
void insertBookSubscription(Book const &book)
Record that this subscriber is following book.
bool insertSubAccountHistory(AccountID const &account)
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.
std::size_t totalSubscriptionCount() const
Return the number of subscriptions currently tracked on this connection.
void setApiVersion(unsigned int apiVersion)
std::uint64_t getSeq() const
resource::Consumer Consumer
void insertSubAccountInfo(AccountID const &account, bool rt)
void deleteBookSubscription(Book const &book)
Stop tracking book for this subscriber.
bool hasAccountHistorySubscription(AccountID const &account) const
Whether this connection already tracks an account-history for account.
hash_set< AccountID > accountHistorySubscriptions_
hash_set< AccountID > normalSubscriptions_
hash_set< Book > bookSubscriptions_
hash_set< AccountID > realTimeSubscriptions_
void deleteSubAccountInfo(AccountID const &account, bool rt)
void deleteSubAccountHistory(AccountID const &account)
unsigned int getApiVersion() const noexcept
std::shared_ptr< InfoSubRequest > const & getRequest()
std::shared_ptr< InfoSubRequest > request_
An endpoint that consumes resources.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
constexpr bool exceedsSubscriptionCap(std::size_t current, std::size_t additional, std::size_t cap=kMaxSubscriptionsPerConnection)
Whether adding additional subscriptions to a connection already holding current would exceed the cap.