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