20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/ledger/OrderBookDB.h>
22 #include <ripple/app/main/Application.h>
23 #include <ripple/app/misc/NetworkOPs.h>
24 #include <ripple/basics/Log.h>
25 #include <ripple/core/Config.h>
26 #include <ripple/core/JobQueue.h>
27 #include <ripple/protocol/Indexes.h>
32 : app_(app), seq_(0), j_(app.journal(
"OrderBookDB"))
41 JLOG(
j_.
warn()) <<
"Eliding full order book update: no ledger";
49 if ((seq > ledger->seq()) && ((ledger->seq() - seq) < 25600))
52 if ((ledger->seq() <= seq) && ((seq - ledger->seq()) < 16))
59 JLOG(
j_.
debug()) <<
"Full order book update: " << seq <<
" to "
70 [
this, ledger]() { update(ledger); });
81 if (
auto const seq =
seq_.
load(); seq > ledger->seq())
83 JLOG(
j_.
debug()) <<
"Eliding update for " << ledger->seq()
84 <<
" because of pending update to later " << seq;
94 JLOG(
j_.
debug()) <<
"Beginning update (" << ledger->seq() <<
")";
101 for (
auto& sle : ledger->sles)
106 <<
"Update halted because the process is stopping";
122 allBooks[book.
in].insert(book.
out);
125 xrpBooks.insert(book.
in);
133 JLOG(
j_.
info()) <<
"Missing node in " << ledger->seq()
134 <<
" during update: " << mn.
what();
139 JLOG(
j_.
debug()) <<
"Update completed (" << ledger->seq() <<
"): " << cnt
175 ret.
reserve(it->second.size());
177 for (
auto const& gets : it->second)
190 return static_cast<int>(it->second.size());
209 ret = std::make_shared<BookListeners>();
254 auto process = [&,
this](
SField const& field) {
255 if (
auto data =
dynamic_cast<STObject const*
>(
256 node.peekAtPField(field));
264 listeners->publish(jvObj, havePublished);
281 <<
"processTxn: field not found (" << ex.
what() <<
")";
const SF_UINT256 sfRootIndex
A currency issued by an account.
std::recursive_mutex mLock
const SF_UINT160 sfTakerPaysCurrency
const SField sfFinalFields
std::atomic< std::uint32_t > seq_
virtual bool isStopping() const =0
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
void update(std::shared_ptr< ReadView const > const &ledger)
const SF_UINT160 sfTakerGetsCurrency
const SField sfDeletedNode
hash_set< Issue > xrpBooks_
virtual NetworkOPs & getOPs()=0
@ ltDIR_NODE
A ledger object which contains a list of object identifiers.
bool isBookToXRP(Issue const &)
const SF_UINT160 sfTakerGetsIssuer
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)
virtual bool isNeedNetworkLedger()=0
virtual LedgerMaster & getLedgerMaster()=0
virtual Config & config()=0
virtual JobQueue & getJobQueue()=0
A transaction that is in a closed ledger.
const SField sfModifiedNode
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 &)
hardened_hash_map< Issue, hardened_hash_set< Issue > > allBooks_
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
TxMeta const & getMeta() const
const SF_UINT160 sfTakerPaysIssuer
const SField sfCreatedNode
OrderBookDB(Application &app)
std::vector< Book > getBooksByTakerPays(Issue const &)
void addOrderBook(Book const &)