diff --git a/modules/ripple_main/ripple_main.cpp b/modules/ripple_main/ripple_main.cpp index 15279c65b3..bc114e3f7e 100644 --- a/modules/ripple_main/ripple_main.cpp +++ b/modules/ripple_main/ripple_main.cpp @@ -143,6 +143,7 @@ #include "src/cpp/ripple/ripple_InfoSub.h" #include "src/cpp/ripple/ripple_HashedObject.h" #include "src/cpp/ripple/ripple_HashedObjectStore.h" +#include "src/cpp/ripple/ripple_OrderBook.h" #include "src/cpp/ripple/ripple_SHAMapSyncFilters.h" // Abstract interfaces @@ -220,7 +221,6 @@ #include "src/cpp/ripple/Offer.h" #include "src/cpp/ripple/OfferCancelTransactor.h" #include "src/cpp/ripple/OfferCreateTransactor.h" -#include "src/cpp/ripple/OrderBook.h" #include "src/cpp/ripple/ripple_PathRequest.h" #include "src/cpp/ripple/ParameterTable.h" #include "src/cpp/ripple/ParseSection.h" @@ -292,7 +292,6 @@ static const uint64 tenTo17m1 = tenTo17 - 1; #include "src/cpp/ripple/OfferCancelTransactor.cpp" #include "src/cpp/ripple/OfferCreateTransactor.cpp" #include "src/cpp/ripple/Operation.cpp" // no log -#include "src/cpp/ripple/OrderBook.cpp" // no log #include "src/cpp/ripple/OrderBookDB.cpp" #endif @@ -382,6 +381,7 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength) #include "src/cpp/ripple/ripple_LoadMonitor.cpp" #include "src/cpp/ripple/ripple_LogWebsockets.cpp" #include "src/cpp/ripple/ripple_LoadFeeTrack.cpp" +#include "src/cpp/ripple/ripple_OrderBook.cpp" #include "src/cpp/ripple/ripple_PathRequest.cpp" #include "src/cpp/ripple/ripple_Peer.cpp" #include "src/cpp/ripple/ripple_Peers.cpp" diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 214174924b..b0ec5b98d5 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -954,7 +954,7 @@ true true - + true true true @@ -1740,7 +1740,7 @@ - + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index db5d2c773a..1d775480c6 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -666,9 +666,6 @@ 1. Modules\ripple_main\_unfactored\ledger - - 1. Modules\ripple_main\_unfactored\ledger - 1. Modules\ripple_main\_unfactored\ledger @@ -843,6 +840,9 @@ 1. Modules\ripple_data\utility + + 1. Modules\ripple_main\refactored + @@ -1403,9 +1403,6 @@ 1. Modules\ripple_main\_unfactored\ledger - - 1. Modules\ripple_main\_unfactored\ledger - 1. Modules\ripple_main\_unfactored\ledger @@ -1592,6 +1589,9 @@ 1. Modules\ripple_data\utility + + 1. Modules\ripple_main\refactored + diff --git a/src/cpp/ripple/OrderBook.cpp b/src/cpp/ripple/OrderBook.cpp deleted file mode 100644 index f46c853624..0000000000 --- a/src/cpp/ripple/OrderBook.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -OrderBook::OrderBook(SerializedLedgerEntry::ref ledgerEntry) -{ - const STAmount saTakerGets = ledgerEntry->getFieldAmount(sfTakerGets); - const STAmount saTakerPays = ledgerEntry->getFieldAmount(sfTakerPays); - - mCurrencyIn = saTakerPays.getCurrency(); - mCurrencyOut = saTakerGets.getCurrency(); - mIssuerIn = saTakerPays.getIssuer(); - mIssuerOut = saTakerGets.getIssuer(); - - mBookBase=Ledger::getBookBase(mCurrencyIn, mIssuerIn, mCurrencyOut, mIssuerOut); -} - - -// vim:ts=4 diff --git a/src/cpp/ripple/OrderBook.h b/src/cpp/ripple/OrderBook.h deleted file mode 100644 index 1e487cff90..0000000000 --- a/src/cpp/ripple/OrderBook.h +++ /dev/null @@ -1,45 +0,0 @@ - -#ifndef ORDERBOOK_H -#define ORDERBOOK_H - -/* - Encapsulates the SLE for an orderbook -*/ -class OrderBook -{ -public: - typedef boost::shared_ptr pointer; - typedef const boost::shared_ptr& ref; - - OrderBook(uint256 const& index, const uint160& ci, const uint160& co, const uint160& ii, const uint160& io) : - mBookBase(index), - mCurrencyIn(ci), - mCurrencyOut(co), - mIssuerIn(ii), - mIssuerOut(io) - { ; } - - uint256& getBookBase(){ return(mBookBase); } - uint160& getCurrencyIn(){ return(mCurrencyIn); } - uint160& getCurrencyOut(){ return(mCurrencyOut); } - uint160& getIssuerIn(){ return(mIssuerIn); } - uint160& getIssuerOut(){ return(mIssuerOut); } - - // looks through the best offers to see how much it would cost to take the given amount - STAmount& getTakePrice(STAmount& takeAmount); - -private: - uint256 mBookBase; - - uint160 mCurrencyIn; - uint160 mCurrencyOut; - uint160 mIssuerIn; - uint160 mIssuerOut; - - //SerializedLedgerEntry::pointer mLedgerEntry; - OrderBook(SerializedLedgerEntry::ref ledgerEntry); // For accounts in a ledger -}; - -#endif - -// vim:ts=4 diff --git a/src/cpp/ripple/OrderBookDB.cpp b/src/cpp/ripple/OrderBookDB.cpp index 3f58f31016..7420f12da9 100644 --- a/src/cpp/ripple/OrderBookDB.cpp +++ b/src/cpp/ripple/OrderBookDB.cpp @@ -44,6 +44,7 @@ void OrderBookDB::setup(Ledger::ref ledger) uint256 index = Ledger::getBookBase(ci, ii, co, io); if (mSeen.insert(index).second) { + // VFALCO TODO Reduce the clunkiness of these parameter wrappers OrderBook::pointer book = boost::make_shared(boost::cref(index), boost::cref(ci), boost::cref(co), boost::cref(ii), boost::cref(io)); diff --git a/src/cpp/ripple/OrderBookDB.h b/src/cpp/ripple/OrderBookDB.h index a7dbedbfeb..6858c258a2 100644 --- a/src/cpp/ripple/OrderBookDB.h +++ b/src/cpp/ripple/OrderBookDB.h @@ -2,9 +2,6 @@ #ifndef ORDERBOOK_DB_H #define ORDERBOOK_DB_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. diff --git a/src/cpp/ripple/ripple_OrderBook.cpp b/src/cpp/ripple/ripple_OrderBook.cpp new file mode 100644 index 0000000000..3f115c4386 --- /dev/null +++ b/src/cpp/ripple/ripple_OrderBook.cpp @@ -0,0 +1,39 @@ + + +OrderBook::OrderBook (uint256 const& index, + uint160 const& currencyIn, + uint160 const& currencyOut, + uint160 const& issuerIn, + uint160 const& issuerOut) + : mBookBase (index) + , mCurrencyIn (currencyIn) + , mCurrencyOut (currencyOut) + , mIssuerIn (issuerIn) + , mIssuerOut (issuerOut) +{ +} + +uint256 const& OrderBook::getBookBase () const +{ + return mBookBase; +} + +uint160 const& OrderBook::getCurrencyIn () const +{ + return mCurrencyIn; +} + +uint160 const& OrderBook::getCurrencyOut () const +{ + return mCurrencyOut; +} + +uint160 const& OrderBook::getIssuerIn () const +{ + return mIssuerIn; +} + +uint160 const& OrderBook::getIssuerOut () const +{ + return mIssuerOut; +} diff --git a/src/cpp/ripple/ripple_OrderBook.h b/src/cpp/ripple/ripple_OrderBook.h new file mode 100644 index 0000000000..828f0977d9 --- /dev/null +++ b/src/cpp/ripple/ripple_OrderBook.h @@ -0,0 +1,50 @@ +#ifndef RIPPLE_ORDERBOOK_H +#define RIPPLE_ORDERBOOK_H + +/** Describes a serialized ledger entry for an order book. +*/ +class OrderBook +{ +public: + typedef boost::shared_ptr pointer; + + typedef boost::shared_ptr const& ref; + +public: + /** Construct from a currency specification. + + @param index ??? + @param currencyIn The base currency. + @param currencyOut The destination currency. + @param issuerIn The base issuer. + @param issuerOut The destination issuer. + */ + // VFALCO NOTE what is the meaning of the index parameter? + // VFALCO TODO group the issuer and currency parameters together. + // VFALCO TODO give typedef names to uint256 / uint160 params + OrderBook (uint256 const& index, + uint160 const& currencyIn, + uint160 const& currencyOut, + uint160 const& issuerIn, + uint160 const& issuerOut); + + uint256 const& getBookBase () const; + + uint160 const& getCurrencyIn () const; + + uint160 const& getCurrencyOut () const; + + uint160 const& getIssuerIn () const; + + uint160 const& getIssuerOut () const; + + +private: + uint256 const mBookBase; + uint160 const mCurrencyIn; + uint160 const mCurrencyOut; + uint160 const mIssuerIn; + uint160 const mIssuerOut; +}; + +#endif