#include "Ledger.h" #include "OrderBook.h" #include // // 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_set mListeners; public: typedef boost::shared_ptr pointer; void addSubscriber(InfoSub* sub); void removeSubscriber(InfoSub* sub); void publish(Json::Value& jvObj); }; class OrderBookDB { std::vector mEmptyVector; std::vector mXRPOrders; std::map > mIssuerMap; //std::vector mAllOrderBooks; // issuerIn, issuerOut, currencyIn, currencyOut std::map > > > mListeners; std::map mKnownMap; public: OrderBookDB(); void setup(Ledger::pointer ledger); // 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& currencyIn,uint160& currencyOut); BookListeners::pointer getBookListeners(uint160 currencyIn, uint160 currencyOut, uint160 issuerIn, uint160 issuerOut); BookListeners::pointer makeBookListeners(uint160 currencyIn, uint160 currencyOut, uint160 issuerIn, uint160 issuerOut); // see if this txn effects any orderbook void processTxn(const SerializedTransaction& stTxn, TER terResult,TransactionMetaSet::pointer& meta,Json::Value& jvObj); }; // vim:ts=4