rippled
Loading...
Searching...
No Matches
OrderBookDB.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_APP_LEDGER_ORDERBOOKDB_H_INCLUDED
21#define RIPPLE_APP_LEDGER_ORDERBOOKDB_H_INCLUDED
22
23#include <xrpld/app/ledger/AcceptedLedgerTx.h>
24#include <xrpld/app/ledger/BookListeners.h>
25#include <xrpld/app/main/Application.h>
26
27#include <xrpl/protocol/MultiApiJson.h>
28#include <xrpl/protocol/UintTypes.h>
29
30#include <mutex>
31#include <optional>
32
33namespace ripple {
34
36{
37public:
38 explicit OrderBookDB(Application& app);
39
40 void
42 void
44
45 void
46 addOrderBook(Book const&);
47
52 Issue const&,
53 std::optional<Domain> const& domain = std::nullopt);
54
57 int
59 Issue const&,
60 std::optional<Domain> const& domain = std::nullopt);
61
62 bool
64
66 getBookListeners(Book const&);
68 makeBookListeners(Book const&);
69
70 // see if this txn effects any orderbook
71 void
74 AcceptedLedgerTx const& alTx,
75 MultiApiJson const& jvObj);
76
77private:
79
80 // Maps order books by "issue in" to "issue out":
82
85
86 // does an order book to XRP exist
88
89 // does an order book to XRP exist
91
93
95
97
99
101};
102
103} // namespace ripple
104
105#endif
A generic endpoint for log messages.
Definition Journal.h:60
A transaction that is in a closed ledger.
Specifies an order book.
Definition Book.h:36
A currency issued by an account.
Definition Issue.h:33
BookListeners::pointer getBookListeners(Book const &)
void addOrderBook(Book const &)
void processTxn(std::shared_ptr< ReadView const > const &ledger, AcceptedLedgerTx const &alTx, MultiApiJson const &jvObj)
BookListeners::pointer makeBookListeners(Book const &)
std::atomic< std::uint32_t > seq_
Definition OrderBookDB.h:98
void update(std::shared_ptr< ReadView const > const &ledger)
int getBookSize(Issue const &, std::optional< Domain > const &domain=std::nullopt)
hardened_hash_map< std::pair< Issue, Domain >, hardened_hash_set< Issue > > domainBooks_
Definition OrderBookDB.h:84
std::recursive_mutex mLock
Definition OrderBookDB.h:92
hash_set< std::pair< Issue, Domain > > xrpDomainBooks_
Definition OrderBookDB.h:90
beast::Journal const j_
BookToListenersMap mListeners
Definition OrderBookDB.h:96
hash_set< Issue > xrpBooks_
Definition OrderBookDB.h:87
hardened_hash_map< Issue, hardened_hash_set< Issue > > allBooks_
Definition OrderBookDB.h:81
void setup(std::shared_ptr< ReadView const > const &ledger)
Application & app_
Definition OrderBookDB.h:78
std::vector< Book > getBooksByTakerPays(Issue const &, std::optional< Domain > const &domain=std::nullopt)
bool isBookToXRP(Issue const &, std::optional< Domain > domain=std::nullopt)
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25