rippled
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 <ripple/app/ledger/AcceptedLedgerTx.h>
24 #include <ripple/app/ledger/BookListeners.h>
25 #include <ripple/app/main/Application.h>
26 #include <mutex>
27 
28 namespace ripple {
29 
31 {
32 public:
33  explicit OrderBookDB(Application& app);
34 
35  void
37  void
39 
40  void
41  addOrderBook(Book const&);
42 
46  getBooksByTakerPays(Issue const&);
47 
50  int
51  getBookSize(Issue const&);
52 
53  bool
54  isBookToXRP(Issue const&);
55 
57  getBookListeners(Book const&);
59  makeBookListeners(Book const&);
60 
61  // see if this txn effects any orderbook
62  void
63  processTxn(
64  std::shared_ptr<ReadView const> const& ledger,
65  const AcceptedLedgerTx& alTx,
66  Json::Value const& jvObj);
67 
68 private:
70 
71  // Maps order books by "issue in" to "issue out":
73 
74  // does an order book to XRP exist
76 
78 
80 
82 
84 
86 };
87 
88 } // namespace ripple
89 
90 #endif
ripple::Application
Definition: Application.h:115
ripple::Issue
A currency issued by an account.
Definition: Issue.h:34
std::shared_ptr
STL class.
std::unordered_set
STL class.
ripple::OrderBookDB::j_
const beast::Journal j_
Definition: OrderBookDB.h:85
ripple::OrderBookDB::mLock
std::recursive_mutex mLock
Definition: OrderBookDB.h:77
std::vector
STL class.
std::recursive_mutex
STL class.
ripple::OrderBookDB::seq_
std::atomic< std::uint32_t > seq_
Definition: OrderBookDB.h:83
ripple::OrderBookDB::update
void update(std::shared_ptr< ReadView const > const &ledger)
Definition: OrderBookDB.cpp:75
ripple::OrderBookDB::xrpBooks_
hash_set< Issue > xrpBooks_
Definition: OrderBookDB.h:75
ripple::OrderBookDB::isBookToXRP
bool isBookToXRP(Issue const &)
Definition: OrderBookDB.cpp:195
ripple::OrderBookDB::getBookSize
int getBookSize(Issue const &)
Definition: OrderBookDB.cpp:186
ripple::OrderBookDB::processTxn
void processTxn(std::shared_ptr< ReadView const > const &ledger, const AcceptedLedgerTx &alTx, Json::Value const &jvObj)
Definition: OrderBookDB.cpp:234
ripple::AcceptedLedgerTx
A transaction that is in a closed ledger.
Definition: AcceptedLedgerTx.h:43
ripple::OrderBookDB::setup
void setup(std::shared_ptr< ReadView const > const &ledger)
Definition: OrderBookDB.cpp:37
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::atomic< std::uint32_t >
ripple::OrderBookDB::makeBookListeners
BookListeners::pointer makeBookListeners(Book const &)
Definition: OrderBookDB.cpp:202
ripple::OrderBookDB
Definition: OrderBookDB.h:30
ripple::OrderBookDB::allBooks_
hardened_hash_map< Issue, hardened_hash_set< Issue > > allBooks_
Definition: OrderBookDB.h:72
ripple::OrderBookDB::mListeners
BookToListenersMap mListeners
Definition: OrderBookDB.h:81
ripple::OrderBookDB::getBookListeners
BookListeners::pointer getBookListeners(Book const &)
Definition: OrderBookDB.cpp:219
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::OrderBookDB::OrderBookDB
OrderBookDB(Application &app)
Definition: OrderBookDB.cpp:31
mutex
ripple::OrderBookDB::app_
Application & app_
Definition: OrderBookDB.h:69
ripple::Book
Specifies an order book.
Definition: Book.h:33
ripple::OrderBookDB::getBooksByTakerPays
std::vector< Book > getBooksByTakerPays(Issue const &)
Definition: OrderBookDB.cpp:166
std::unordered_map
STL class.
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::OrderBookDB::addOrderBook
void addOrderBook(Book const &)
Definition: OrderBookDB.cpp:152