rippled
Loading...
Searching...
No Matches
InfoSub.cpp
1#include <xrpld/rpc/InfoSub.h>
2
3namespace ripple {
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 (synched, unsynched,
12// etectera) and defer to the correct means of processing. The current
13// code assumes this node is synched (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
21 : m_consumer(consumer), m_source(source), mSeq(assign_id())
22{
23}
24
26{
35
36 // Use the internal unsubscribe so that it won't call
37 // back to us and modify its own parameter
38 if (!realTimeSubscriptions_.empty())
40
41 if (!normalSubscriptions_.empty())
43
44 for (auto const& account : accountHistorySubscriptions_)
46}
47
50{
51 return m_consumer;
52}
53
56{
57 return mSeq;
58}
59
60void
64
65void
67{
69
70 if (rt)
71 realTimeSubscriptions_.insert(account);
72 else
73 normalSubscriptions_.insert(account);
74}
75
76void
78{
80
81 if (rt)
82 realTimeSubscriptions_.erase(account);
83 else
84 normalSubscriptions_.erase(account);
85}
86
87bool
89{
91 return accountHistorySubscriptions_.insert(account).second;
92}
93
94void
100
101void
103{
104 request_.reset();
105}
106
107void
112
115{
116 return request_;
117}
118
119void
120InfoSub::setApiVersion(unsigned int apiVersion)
121{
122 apiVersion_ = apiVersion;
123}
124
125unsigned int
127{
128 XRPL_ASSERT(
129 apiVersion_ > 0, "ripple::InfoSub::getApiVersion : valid API version");
130 return apiVersion_;
131}
132
133} // namespace ripple
Abstracts the source of subscription data.
Definition InfoSub.h:49
virtual bool unsubValidations(std::uint64_t uListener)=0
virtual bool unsubServer(std::uint64_t uListener)=0
virtual bool unsubPeerStatus(std::uint64_t uListener)=0
virtual bool unsubConsensus(std::uint64_t uListener)=0
virtual void unsubAccountInternal(std::uint64_t uListener, hash_set< AccountID > const &vnaAccountIDs, bool realTime)=0
virtual bool unsubLedger(std::uint64_t uListener)=0
virtual bool unsubTransactions(std::uint64_t uListener)=0
virtual bool unsubManifests(std::uint64_t uListener)=0
virtual void unsubAccountHistoryInternal(std::uint64_t uListener, AccountID const &account, bool historyOnly)=0
virtual bool unsubRTTransactions(std::uint64_t uListener)=0
std::uint64_t getSeq()
Definition InfoSub.cpp:55
Source & m_source
Definition InfoSub.h:224
std::mutex mLock
Definition InfoSub.h:220
std::shared_ptr< InfoSubRequest > const & getRequest()
Definition InfoSub.cpp:114
hash_set< AccountID > realTimeSubscriptions_
Definition InfoSub.h:225
unsigned int getApiVersion() const noexcept
Definition InfoSub.cpp:126
Consumer m_consumer
Definition InfoSub.h:223
bool insertSubAccountHistory(AccountID const &account)
Definition InfoSub.cpp:88
hash_set< AccountID > normalSubscriptions_
Definition InfoSub.h:226
void deleteSubAccountInfo(AccountID const &account, bool rt)
Definition InfoSub.cpp:77
hash_set< AccountID > accountHistorySubscriptions_
Definition InfoSub.h:229
void setApiVersion(unsigned int apiVersion)
Definition InfoSub.cpp:120
InfoSub(Source &source)
Definition InfoSub.cpp:16
void onSendEmpty()
Definition InfoSub.cpp:61
void insertSubAccountInfo(AccountID const &account, bool rt)
Definition InfoSub.cpp:66
void deleteSubAccountHistory(AccountID const &account)
Definition InfoSub.cpp:95
std::uint64_t mSeq
Definition InfoSub.h:228
void clearRequest()
Definition InfoSub.cpp:102
unsigned int apiVersion_
Definition InfoSub.h:230
std::shared_ptr< InfoSubRequest > request_
Definition InfoSub.h:227
virtual ~InfoSub()
Definition InfoSub.cpp:25
void setRequest(std::shared_ptr< InfoSubRequest > const &req)
Definition InfoSub.cpp:108
Consumer & getConsumer()
Definition InfoSub.cpp:49
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