20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/ledger/OrderBookDB.h>
22 #include <ripple/app/main/Application.h>
23 #include <ripple/basics/Log.h>
24 #include <ripple/core/Config.h>
25 #include <ripple/core/JobQueue.h>
26 #include <ripple/protocol/Indexes.h>
31 : app_(app), mSeq(0), j_(app.journal(
"OrderBookDB"))
47 auto seq = ledger->info().seq;
54 if ((seq >
mSeq) && ((seq -
mSeq) < 256))
56 if ((seq <
mSeq) && ((
mSeq - seq) < 16))
60 JLOG(
j_.
debug()) <<
"Advancing from " <<
mSeq <<
" to " << seq;
86 JLOG(
j_.
debug()) <<
"OrderBookDB::update>";
99 for (
auto& sle : ledger->sles)
104 <<
"OrderBookDB::update exiting due to isStopping";
121 if (seen.
insert(index).second)
123 auto orderBook = std::make_shared<OrderBook>(index, book);
124 sourceMap[book.
in].push_back(orderBook);
125 destMap[book.
out].push_back(orderBook);
135 JLOG(
j_.
info()) <<
"OrderBookDB::update: " << mn.
what();
141 JLOG(
j_.
debug()) <<
"OrderBookDB::update< " << books <<
" books found";
164 if (
isXRP(ob->getCurrencyOut()))
172 if (ob->getCurrencyIn() == book.
in.
currency &&
180 auto orderBook = std::make_shared<OrderBook>(index, book);
220 ret = std::make_shared<BookListeners>();
263 for (
auto& node : alTx.
getMeta()->getNodes())
269 SField const* field =
nullptr;
282 auto data =
dynamic_cast<const STObject*
>(
283 node.peekAtPField(*field));
296 listeners->publish(jvObj, havePublished);
305 <<
"Fields not found in OrderBookDB::processTxn";
A currency issued by an account.
const SF_HASH160 sfTakerGetsCurrency
std::recursive_mutex mLock
uint256 getBookBase(Book const &book)
std::vector< pointer > List
IssueToOrderBook mDestMap
const SField sfFinalFields
virtual bool isStopping() const =0
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
OrderBook::List getBooksByTakerPays(Issue const &)
void update(std::shared_ptr< ReadView const > const &ledger)
const SField sfDeletedNode
const SF_HASH160 sfTakerGetsIssuer
@ ltDIR_NODE
A ledger object which contains a list of object identifiers.
bool isBookToXRP(Issue const &)
const SF_AMOUNT sfTakerPays
@ ltOFFER
A ledger object which describes an offer on the DEX.
int getBookSize(Issue const &)
void processTxn(std::shared_ptr< ReadView const > const &ledger, const AcceptedLedgerTx &alTx, Json::Value const &jvObj)
std::shared_ptr< TxMeta > const & getMeta() const
virtual LedgerMaster & getLedgerMaster()=0
const SF_HASH160 sfTakerPaysIssuer
virtual Config & config()=0
virtual JobQueue & getJobQueue()=0
A transaction that is in a closed ledger.
const SField sfModifiedNode
IssueToOrderBook mSourceMap
const SF_AMOUNT sfTakerGets
void setup(std::shared_ptr< ReadView const > const &ledger)
bool isXRP(AccountID const &c)
const SF_UINT64 sfExchangeRate
BookListeners::pointer makeBookListeners(Book const &)
const SF_HASH160 sfTakerPaysCurrency
BookToListenersMap mListeners
const SField sfPreviousFields
BookListeners::pointer getBookListeners(Book const &)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const SF_UINT16 sfLedgerEntryType
const SField sfCreatedNode
OrderBookDB(Application &app)
const SF_HASH256 sfRootIndex
hash_set< Issue > mXRPBooks
void addOrderBook(Book const &)