first draft

This commit is contained in:
jed
2013-02-05 13:04:38 -08:00
parent 62f6d030c6
commit eb27240610
9 changed files with 200 additions and 20 deletions

View File

@@ -1,11 +1,24 @@
#include "Ledger.h"
#include "OrderBook.h"
#include <boost/shared_ptr.hpp>
/*
we can 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<InfoSub*> mListeners;
public:
typedef boost::shared_ptr<BookListeners> pointer;
void addSubscriber(InfoSub* sub);
void removeSubscriber(InfoSub* sub);
void publish(Json::Value& jvObj);
};
class OrderBookDB
{
std::vector<OrderBook::pointer> mEmptyVector;
@@ -13,6 +26,9 @@ class OrderBookDB
std::map<uint160, std::vector<OrderBook::pointer> > mIssuerMap;
//std::vector<OrderBook::pointer> mAllOrderBooks;
// issuerIn, issuerOut, currencyIn, currencyOut
std::map<uint160, std::map<uint160, std::map<uint160, std::map<uint160, BookListeners::pointer> > > > mListeners;
std::map<uint256, bool > mKnownMap;
public:
@@ -30,10 +46,11 @@ public:
float getPrice(uint160& currencyIn,uint160& currencyOut);
OrderBook::pointer getBook(uint160 mCurrencyIn, uint160 mCurrencyOut, uint160 mIssuerIn, uint160 mIssuerOut);
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