rippled
Loading...
Searching...
No Matches
BookListeners.cpp
1#include <xrpl/ledger/BookListeners.h>
2
3namespace xrpl {
4
5void
7{
9 mListeners[sub->getSeq()] = sub;
10}
11
12void
18
19void
21{
23 auto it = mListeners.cbegin();
24
25 while (it != mListeners.cend())
26 {
27 InfoSub::pointer p = it->second.lock();
28
29 if (p)
30 {
31 // Only publish jvObj if this is the first occurrence
32 if (havePublished.emplace(p->getSeq()).second)
33 {
34 jvObj.visit(
35 p->getApiVersion(), //
36 [&](Json::Value const& jv) { p->send(jv, true); });
37 }
38 ++it;
39 }
40 else
41 it = mListeners.erase(it);
42 }
43}
44
45} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
std::recursive_mutex mLock
void removeSubscriber(std::uint64_t sub)
Stop publishing to a subscriber.
void addSubscriber(InfoSub::ref sub)
Add a new subscription for this book.
void publish(MultiApiJson const &jvObj, hash_set< std::uint64_t > &havePublished)
Publish a transaction to subscribers.
hash_map< std::uint64_t, InfoSub::wptr > mListeners
T emplace(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5