#ifndef ORDERBOOK_DB_H #define ORDERBOOK_DB_H #include #include #include "Ledger.h" #include "AcceptedLedger.h" #include "OrderBook.h" // // XXX Eventually make this cached and just update it as transactions come in. // But, for now it is probably faster to just generate it each time. // class BookListeners { boost::unordered_map mListeners; boost::recursive_mutex mLock; public: typedef boost::shared_ptr pointer; void addSubscriber(InfoSub::ref sub); void removeSubscriber(uint64 sub); void publish(Json::Value& jvObj); }; class OrderBookDB { std::vector mEmptyVector; std::vector mXRPOrders; boost::unordered_map > mIssuerMap; //std::vector mAllOrderBooks; // issuerPays, issuerGets, currencyPays, currencyGets std::map > > > mListeners; uint32 mSeq; boost::recursive_mutex mLock; public: OrderBookDB(); void setup(Ledger::ref ledger); void invalidate(); // return list of all orderbooks that want XRP std::vector& getXRPInBooks(){ return mXRPOrders; } // return list of all orderbooks that want IssuerID std::vector& getBooks(const uint160& issuerID); // return list of all orderbooks that want this issuerID and currencyID void getBooks(const uint160& issuerID, const uint160& currencyID, std::vector& bookRet); // returns the best rate we can find float getPrice(uint160& currencyPays,uint160& currencyGets); BookListeners::pointer getBookListeners(const uint160& currencyPays, const uint160& currencyGets, const uint160& issuerPays, const uint160& issuerGets); BookListeners::pointer makeBookListeners(const uint160& currencyPays, const uint160& currencyGets, const uint160& issuerPays, const uint160& issuerGets); // see if this txn effects any orderbook void processTxn(Ledger::ref ledger, const ALTransaction& alTx, Json::Value& jvObj); }; #endif // vim:ts=4