rippled
Loading...
Searching...
No Matches
OrderBookDBImpl.h
1#pragma once
2
3#include <xrpl/core/ServiceRegistry.h>
4#include <xrpl/ledger/AcceptedLedgerTx.h>
5#include <xrpl/ledger/BookListeners.h>
6#include <xrpl/ledger/OrderBookDB.h>
7#include <xrpl/protocol/MultiApiJson.h>
8#include <xrpl/protocol/UintTypes.h>
9
10#include <mutex>
11#include <optional>
12
13namespace xrpl {
14
21
29make_OrderBookDB(ServiceRegistry& registry, OrderBookDBConfig const& config);
30
31class OrderBookDBImpl final : public OrderBookDB
32{
33public:
34 OrderBookDBImpl(ServiceRegistry& registry, OrderBookDBConfig const& config);
35
36 // OrderBookDB interface implementation
37 void
38 setup(std::shared_ptr<ReadView const> const& ledger) override;
39
40 void
41 addOrderBook(Book const& book) override;
42
44 getBooksByTakerPays(Issue const& issue, std::optional<Domain> const& domain = std::nullopt)
45 override;
46
47 int
48 getBookSize(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) override;
49
50 bool
51 isBookToXRP(Issue const& issue, std::optional<Domain> const& domain = std::nullopt) override;
52
53 // OrderBookDBImpl-specific methods
54 void
56
57 // see if this txn effects any orderbook
58 void
61 AcceptedLedgerTx const& alTx,
62 MultiApiJson const& jvObj) override;
63
65 getBookListeners(Book const&) override;
67 makeBookListeners(Book const&) override;
68
69private:
71 int const pathSearchMax_;
72 bool const standalone_;
73
74 // Maps order books by "issue in" to "issue out":
76
78
79 // does an order book to XRP exist
81
82 // does an order book to XRP exist
84
86
88
90
92
94};
95
96} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
A transaction that is in a closed ledger.
Specifies an order book.
Definition Book.h:16
A currency issued by an account.
Definition Issue.h:13
hardened_hash_map< std::pair< Issue, Domain >, hardened_hash_set< Issue > > domainBooks_
void addOrderBook(Book const &book) override
Add an order book to track.
BookListeners::pointer makeBookListeners(Book const &) override
Create a new book listeners for a book.
BookListeners::pointer getBookListeners(Book const &) override
Get the book listeners for a book.
BookToListenersMap mListeners
int getBookSize(Issue const &issue, std::optional< Domain > const &domain=std::nullopt) override
Get the count of order books that want a specific issue.
hash_set< Issue > xrpBooks_
void setup(std::shared_ptr< ReadView const > const &ledger) override
Initialize or update the order book database with a new ledger.
hash_set< std::pair< Issue, Domain > > xrpDomainBooks_
hardened_hash_map< Issue, hardened_hash_set< Issue > > allBooks_
std::atomic< std::uint32_t > seq_
void processTxn(std::shared_ptr< ReadView const > const &ledger, AcceptedLedgerTx const &alTx, MultiApiJson const &jvObj) override
Process a transaction for order book tracking.
std::vector< Book > getBooksByTakerPays(Issue const &issue, std::optional< Domain > const &domain=std::nullopt) override
Get all order books that want a specific issue.
void update(std::shared_ptr< ReadView const > const &ledger)
bool isBookToXRP(Issue const &issue, std::optional< Domain > const &domain=std::nullopt) override
Check if an order book to XRP exists for the given issue.
std::reference_wrapper< ServiceRegistry > registry_
beast::Journal const j_
std::recursive_mutex mLock
Tracks order books in the ledger.
Definition OrderBookDB.h:29
Service registry for dependency injection.
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::unique_ptr< OrderBookDB > make_OrderBookDB(ServiceRegistry &registry, OrderBookDBConfig const &config)
Create an OrderBookDB instance.
Configuration for OrderBookDB.