xrpld
Loading...
Searching...
No Matches
OrderBookDBImpl.h
1#pragma once
2
3#include <xrpl/core/ServiceRegistry.h>
4#include <xrpl/ledger/OrderBookDB.h>
5#include <xrpl/protocol/UintTypes.h>
6
7#include <mutex>
8#include <optional>
9
10namespace xrpl {
11
18
26makeOrderBookDb(ServiceRegistry& registry, OrderBookDBConfig const& config);
27
28class OrderBookDBImpl final : public OrderBookDB
29{
30public:
31 OrderBookDBImpl(ServiceRegistry& registry, OrderBookDBConfig const& config);
32
33 // OrderBookDB interface implementation
34 void
35 setup(std::shared_ptr<ReadView const> const& ledger) override;
36
37 void
38 addOrderBook(Book const& book) override;
39
41 getBooksByTakerPays(Asset const& asset, std::optional<Domain> const& domain = std::nullopt)
42 override;
43
44 int
45 getBookSize(Asset const& asset, std::optional<Domain> const& domain = std::nullopt) override;
46
47 bool
48 isBookToXRP(Asset const& asset, std::optional<Domain> const& domain = std::nullopt) override;
49
50 // OrderBookDBImpl-specific methods
51 void
53
54private:
56 int const pathSearchMax_;
57 bool const standalone_;
58
59 // Maps order books by "asset in" to "asset out":
61
63
64 // does an order book to XRP exist
66
67 // does an order book to XRP exist
69
71
73
75};
76
77} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:38
Specifies an order book.
Definition Book.h:16
hardened_hash_map< std::pair< Asset, Domain >, hardened_hash_set< Asset > > domainBooks_
void addOrderBook(Book const &book) override
Add an order book to track.
std::vector< Book > getBooksByTakerPays(Asset const &asset, std::optional< Domain > const &domain=std::nullopt) override
Get all order books that want a specific issue.
hash_set< Asset > xrpBooks_
void setup(std::shared_ptr< ReadView const > const &ledger) override
Initialize or update the order book database with a new ledger.
bool isBookToXRP(Asset const &asset, std::optional< Domain > const &domain=std::nullopt) override
Check if an order book to XRP exists for the given issue.
OrderBookDBImpl(ServiceRegistry &registry, OrderBookDBConfig const &config)
hardened_hash_map< Asset, hardened_hash_set< Asset > > allBooks_
std::atomic< std::uint32_t > seq_
int getBookSize(Asset const &asset, std::optional< Domain > const &domain=std::nullopt) override
Get the count of order books that want a specific issue.
hash_set< std::pair< Asset, Domain > > xrpDomainBooks_
void update(std::shared_ptr< ReadView const > const &ledger)
std::recursive_mutex lock_
std::reference_wrapper< ServiceRegistry > registry_
beast::Journal const j_
Tracks order books in the ledger.
Definition OrderBookDB.h:29
Service registry for dependency injection.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
std::unordered_set< Value, Hash, Pred, Allocator > hardened_hash_set
std::unordered_map< Key, Value, Hash, Pred, Allocator > hardened_hash_map
std::unique_ptr< OrderBookDB > makeOrderBookDb(ServiceRegistry &registry, OrderBookDBConfig const &config)
Create an OrderBookDB instance.
Configuration for OrderBookDB.