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 <ripple/app/misc/OrderBook.h>
27 #include <mutex>
28 
29 namespace ripple {
30 
32  : public Stoppable
33 {
34 public:
35  OrderBookDB (Application& app, Stoppable& parent);
36 
37  void setup (std::shared_ptr<ReadView const> const& ledger);
38  void update (std::shared_ptr<ReadView const> const& ledger);
39  void invalidate ();
40 
41  void addOrderBook(Book const&);
42 
46 
49  int getBookSize(Issue const&);
50 
51  bool isBookToXRP (Issue const&);
52 
55 
56  // see if this txn effects any orderbook
57  void processTxn (
58  std::shared_ptr<ReadView const> const& ledger,
59  const AcceptedLedgerTx& alTx, Json::Value const& jvObj);
60 
62 
63 private:
64  void rawAddBook(Book const&);
65 
67 
68  // by ci/ii
70 
71  // by co/io
73 
74  // does an order book to XRP exist
76 
78 
80 
82 
84 
86 };
87 
88 } // ripple
89 
90 #endif
ripple::Application
Definition: Application.h:85
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::mDestMap
IssueToOrderBook mDestMap
Definition: OrderBookDB.h:72
ripple::OrderBookDB::getBooksByTakerPays
OrderBook::List getBooksByTakerPays(Issue const &)
Definition: OrderBookDB.cpp:192
ripple::OrderBookDB::update
void update(std::shared_ptr< ReadView const > const &ledger)
Definition: OrderBookDB.cpp:80
ripple::OrderBookDB::invalidate
void invalidate()
Definition: OrderBookDB.cpp:38
ripple::OrderBookDB::OrderBookDB
OrderBookDB(Application &app, Stoppable &parent)
Definition: OrderBookDB.cpp:30
ripple::OrderBookDB::isBookToXRP
bool isBookToXRP(Issue const &)
Definition: OrderBookDB.cpp:205
ripple::Stoppable
Provides an interface for starting and stopping.
Definition: Stoppable.h:200
ripple::OrderBookDB::getBookSize
int getBookSize(Issue const &)
Definition: OrderBookDB.cpp:199
ripple::OrderBookDB::processTxn
void processTxn(std::shared_ptr< ReadView const > const &ledger, const AcceptedLedgerTx &alTx, Json::Value const &jvObj)
Definition: OrderBookDB.cpp:241
ripple::AcceptedLedgerTx
A transaction that is in a closed ledger.
Definition: AcceptedLedgerTx.h:50
ripple::OrderBookDB::mSourceMap
IssueToOrderBook mSourceMap
Definition: OrderBookDB.h:69
ripple::OrderBookDB::setup
void setup(std::shared_ptr< ReadView const > const &ledger)
Definition: OrderBookDB.cpp:44
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
std::uint32_t
ripple::OrderBookDB::makeBookListeners
BookListeners::pointer makeBookListeners(Book const &)
Definition: OrderBookDB.cpp:211
ripple::OrderBookDB
Definition: OrderBookDB.h:31
ripple::OrderBookDB::mSeq
std::uint32_t mSeq
Definition: OrderBookDB.h:83
ripple::OrderBookDB::mListeners
BookToListenersMap mListeners
Definition: OrderBookDB.h:81
ripple::OrderBookDB::getBookListeners
BookListeners::pointer getBookListeners(Book const &)
Definition: OrderBookDB.cpp:227
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
mutex
ripple::OrderBookDB::mXRPBooks
hash_set< Issue > mXRPBooks
Definition: OrderBookDB.h:75
ripple::OrderBookDB::app_
Application & app_
Definition: OrderBookDB.h:66
ripple::Book
Specifies an order book.
Definition: Book.h:32
ripple::OrderBookDB::rawAddBook
void rawAddBook(Book const &)
std::unordered_map
STL class.
Json::Value
Represents a JSON value.
Definition: json_value.h:141
ripple::OrderBookDB::addOrderBook
void addOrderBook(Book const &)
Definition: OrderBookDB.cpp:156