rippled
Loading...
Searching...
No Matches
InfoSub.cpp
1#include <xrpld/rpc/InfoSub.h>
2
3namespace xrpl {
4
5// This is the primary interface into the "client" portion of the program.
6// Code that wants to do normal operations on the network such as
7// creating and monitoring accounts, creating transactions, and so on
8// should use this interface. The RPC code will primarily be a light wrapper
9// over this code.
10
11// Eventually, it will check the node's operating mode (synced, unsynced,
12// etcetera) and defer to the correct means of processing. The current
13// code assumes this node is synced (and will continue to do so until
14// there's a functional network.
15
16InfoSub::InfoSub(Source& source) : m_source(source), mSeq(assign_id())
17{
18}
19
20InfoSub::InfoSub(Source& source, Consumer consumer) : m_consumer(consumer), m_source(source), mSeq(assign_id())
21{
22}
23
25{
34
35 // Use the internal unsubscribe so that it won't call
36 // back to us and modify its own parameter
37 if (!realTimeSubscriptions_.empty())
39
40 if (!normalSubscriptions_.empty())
42
43 for (auto const& account : accountHistorySubscriptions_)
45}
46
49{
50 return m_consumer;
51}
52
55{
56 return mSeq;
57}
58
59void
63
64void
66{
68
69 if (rt)
70 realTimeSubscriptions_.insert(account);
71 else
72 normalSubscriptions_.insert(account);
73}
74
75void
77{
79
80 if (rt)
81 realTimeSubscriptions_.erase(account);
82 else
83 normalSubscriptions_.erase(account);
84}
85
86bool
88{
90 return accountHistorySubscriptions_.insert(account).second;
91}
92
93void
99
100void
102{
103 request_.reset();
104}
105
106void
111
114{
115 return request_;
116}
117
118void
119InfoSub::setApiVersion(unsigned int apiVersion)
120{
121 apiVersion_ = apiVersion;
122}
123
124unsigned int
126{
127 XRPL_ASSERT(apiVersion_ > 0, "xrpl::InfoSub::getApiVersion : valid API version");
128 return apiVersion_;
129}
130
131} // namespace xrpl
Abstracts the source of subscription data.
Definition InfoSub.h:49
virtual void unsubAccountHistoryInternal(std::uint64_t uListener, AccountID const &account, bool historyOnly)=0
virtual bool unsubRTTransactions(std::uint64_t uListener)=0
virtual bool unsubConsensus(std::uint64_t uListener)=0
virtual bool unsubTransactions(std::uint64_t uListener)=0
virtual void unsubAccountInternal(std::uint64_t uListener, hash_set< AccountID > const &vnaAccountIDs, bool realTime)=0
virtual bool unsubServer(std::uint64_t uListener)=0
virtual bool unsubLedger(std::uint64_t uListener)=0
virtual bool unsubPeerStatus(std::uint64_t uListener)=0
virtual bool unsubManifests(std::uint64_t uListener)=0
virtual bool unsubValidations(std::uint64_t uListener)=0
Source & m_source
Definition InfoSub.h:209
void setRequest(std::shared_ptr< InfoSubRequest > const &req)
Definition InfoSub.cpp:107
InfoSub(Source &source)
Definition InfoSub.cpp:16
void clearRequest()
Definition InfoSub.cpp:101
bool insertSubAccountHistory(AccountID const &account)
Definition InfoSub.cpp:87
Consumer & getConsumer()
Definition InfoSub.cpp:48
void setApiVersion(unsigned int apiVersion)
Definition InfoSub.cpp:119
virtual ~InfoSub()
Definition InfoSub.cpp:24
void insertSubAccountInfo(AccountID const &account, bool rt)
Definition InfoSub.cpp:65
hash_set< AccountID > accountHistorySubscriptions_
Definition InfoSub.h:214
hash_set< AccountID > normalSubscriptions_
Definition InfoSub.h:211
std::uint64_t mSeq
Definition InfoSub.h:213
hash_set< AccountID > realTimeSubscriptions_
Definition InfoSub.h:210
std::mutex mLock
Definition InfoSub.h:205
void deleteSubAccountInfo(AccountID const &account, bool rt)
Definition InfoSub.cpp:76
void deleteSubAccountHistory(AccountID const &account)
Definition InfoSub.cpp:94
unsigned int getApiVersion() const noexcept
Definition InfoSub.cpp:125
Consumer m_consumer
Definition InfoSub.h:208
unsigned int apiVersion_
Definition InfoSub.h:215
void onSendEmpty()
Definition InfoSub.cpp:60
std::uint64_t getSeq()
Definition InfoSub.cpp:54
std::shared_ptr< InfoSubRequest > const & getRequest()
Definition InfoSub.cpp:113
std::shared_ptr< InfoSubRequest > request_
Definition InfoSub.h:212
An endpoint that consumes resources.
Definition Consumer.h:17
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6