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>
34 , j_(app.journal(
"OrderBookDB"))
50 auto seq = ledger->info().seq;
57 if ((seq >
mSeq) && ((seq -
mSeq) < 256))
59 if ((seq <
mSeq) && ((
mSeq - seq) < 16))
63 JLOG(
j_.
debug()) <<
"Advancing from " <<
mSeq <<
" to " << seq;
89 JLOG(
j_.
debug()) <<
"OrderBookDB::update>";
102 for (
auto& sle : ledger->sles)
107 <<
"OrderBookDB::update exiting due to isStopping";
124 if (seen.
insert(index).second)
126 auto orderBook = std::make_shared<OrderBook>(index, book);
127 sourceMap[book.
in].push_back(orderBook);
128 destMap[book.
out].push_back(orderBook);
138 JLOG(
j_.
info()) <<
"OrderBookDB::update: " << mn.
what();
144 JLOG(
j_.
debug()) <<
"OrderBookDB::update< " << books <<
" books found";
167 if (
isXRP(ob->getCurrencyOut()))
175 if (ob->getCurrencyIn() == book.
in.
currency &&
183 auto orderBook = std::make_shared<OrderBook>(index, book);
223 ret = std::make_shared<BookListeners>();
266 for (
auto& node : alTx.
getMeta()->getNodes())
272 SField const* field =
nullptr;
285 auto data =
dynamic_cast<const STObject*
>(
286 node.peekAtPField(*field));
299 listeners->publish(jvObj, havePublished);
308 <<
"Fields not found in OrderBookDB::processTxn";
const SField sfPreviousFields(access, STI_OBJECT, 6, "PreviousFields")
A currency issued by an account.
const SF_U16 sfLedgerEntryType(access, STI_UINT16, 1, "LedgerEntryType", SField::sMD_Never)
std::recursive_mutex mLock
uint256 getBookBase(Book const &book)
const SF_U160 sfTakerPaysIssuer(access, STI_HASH160, 2, "TakerPaysIssuer")
const SField sfNewFields(access, STI_OBJECT, 8, "NewFields")
std::vector< pointer > List
const SF_Amount sfTakerPays(access, STI_AMOUNT, 4, "TakerPays")
IssueToOrderBook mDestMap
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
const SF_U160 sfTakerGetsCurrency(access, STI_HASH160, 3, "TakerGetsCurrency")
OrderBook::List getBooksByTakerPays(Issue const &)
void update(std::shared_ptr< ReadView const > const &ledger)
const SField sfFinalFields(access, STI_OBJECT, 7, "FinalFields")
const SField sfModifiedNode(access, STI_OBJECT, 5, "ModifiedNode")
OrderBookDB(Application &app, Stoppable &parent)
bool isBookToXRP(Issue const &)
Provides an interface for starting and stopping.
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
virtual Config & config()=0
virtual JobQueue & getJobQueue()=0
A transaction that is in a closed ledger.
IssueToOrderBook mSourceMap
const SF_U64 sfExchangeRate(access, STI_UINT64, 6, "ExchangeRate")
void setup(std::shared_ptr< ReadView const > const &ledger)
bool isXRP(AccountID const &c)
const SField sfCreatedNode(access, STI_OBJECT, 3, "CreatedNode")
BookListeners::pointer makeBookListeners(Book const &)
BookToListenersMap mListeners
BookListeners::pointer getBookListeners(Book const &)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const SF_U160 sfTakerPaysCurrency(access, STI_HASH160, 1, "TakerPaysCurrency")
const SF_Amount sfTakerGets(access, STI_AMOUNT, 5, "TakerGets")
const SF_U256 sfRootIndex(access, STI_HASH256, 8, "RootIndex", SField::sMD_Always)
hash_set< Issue > mXRPBooks
@ ltDIR_NODE
Directory node.
const SField sfDeletedNode(access, STI_OBJECT, 4, "DeletedNode")
bool isStopping() const
Returns true if the stoppable should stop.
const SF_U160 sfTakerGetsIssuer(access, STI_HASH160, 4, "TakerGetsIssuer")
void addOrderBook(Book const &)