mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Tidy up OrderBook
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -954,7 +954,7 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\OrderBook.cpp">
|
||||
<ClCompile Include="src\cpp\ripple\ripple_OrderBook.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
@@ -1740,7 +1740,7 @@
|
||||
<ClInclude Include="src\cpp\ripple\OfferCancelTransactor.h" />
|
||||
<ClInclude Include="src\cpp\ripple\OfferCreateTransactor.h" />
|
||||
<ClInclude Include="src\cpp\ripple\Operation.h" />
|
||||
<ClInclude Include="src\cpp\ripple\OrderBook.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple_OrderBook.h" />
|
||||
<ClInclude Include="src\cpp\ripple\OrderBookDB.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ParameterTable.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ParseSection.h" />
|
||||
|
||||
@@ -666,9 +666,6 @@
|
||||
<ClCompile Include="src\cpp\ripple\Offer.cpp">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\OrderBook.cpp">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\OrderBookDB.cpp">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
@@ -843,6 +840,9 @@
|
||||
<ClCompile Include="modules\ripple_data\utility\ripple_JSONCache.cpp">
|
||||
<Filter>1. Modules\ripple_data\utility</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\ripple_OrderBook.cpp">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="database\sqlite3ext.h">
|
||||
@@ -1403,9 +1403,6 @@
|
||||
<ClInclude Include="src\cpp\ripple\Offer.h">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\OrderBook.h">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\OrderBookDB.h">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClInclude>
|
||||
@@ -1592,6 +1589,9 @@
|
||||
<ClInclude Include="modules\ripple_data\utility\ripple_JSONCache.h">
|
||||
<Filter>1. Modules\ripple_data\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\ripple_OrderBook.h">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="SConstruct" />
|
||||
|
||||
@@ -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
|
||||
@@ -1,45 +0,0 @@
|
||||
|
||||
#ifndef ORDERBOOK_H
|
||||
#define ORDERBOOK_H
|
||||
|
||||
/*
|
||||
Encapsulates the SLE for an orderbook
|
||||
*/
|
||||
class OrderBook
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<OrderBook> pointer;
|
||||
typedef const boost::shared_ptr<OrderBook>& 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
|
||||
@@ -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<OrderBook>(boost::cref(index),
|
||||
boost::cref(ci), boost::cref(co), boost::cref(ii), boost::cref(io));
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
39
src/cpp/ripple/ripple_OrderBook.cpp
Normal file
39
src/cpp/ripple/ripple_OrderBook.cpp
Normal file
@@ -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;
|
||||
}
|
||||
50
src/cpp/ripple/ripple_OrderBook.h
Normal file
50
src/cpp/ripple/ripple_OrderBook.h
Normal file
@@ -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 <OrderBook> pointer;
|
||||
|
||||
typedef boost::shared_ptr <OrderBook> 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
|
||||
Reference in New Issue
Block a user