Correct Pathfinder::getPaths out to handle order books (RIPD-427)

This commit is contained in:
Tom Ritchford
2014-07-29 15:22:45 -04:00
committed by Vinnie Falco
parent 4b905fe9ff
commit 91a227a475
3 changed files with 15 additions and 4 deletions

View File

@@ -173,6 +173,12 @@ OrderBook::List OrderBookDB::getBooksByTakerPays (Issue const& issue)
return it == mSourceMap.end () ? OrderBook::List() : it->second;
}
int OrderBookDB::getBookSize(Issue const& issue) {
ScopedLockType sl (mLock);
auto it = mSourceMap.find (issue);
return it == mSourceMap.end () ? 0 : it->second.size();
}
bool OrderBookDB::isBookToXRP(Issue const& issue)
{
ScopedLockType sl (mLock);

View File

@@ -37,9 +37,14 @@ public:
void addOrderBook(Book const&);
// return list of all orderbooks that want this issuerID and currencyID
/** @return a list of all orderbooks that want this issuerID and currencyID.
*/
OrderBook::List getBooksByTakerPays (Issue const&);
/** @return a count of all orderbooks that want this issuerID and currencyID.
*/
int getBookSize(Issue const&);
bool isBookToXRP (Issue const&);
BookListeners::pointer getBookListeners (Book const&);

View File

@@ -486,12 +486,10 @@ bool Pathfinder::matchesOrigin (Issue const& issue)
issue.account == mSrcAccountID);
}
// VFALCO TODO Use Currency, RippleAccount, et. al. in argument list here
int Pathfinder::getPathsOut (
Currency const& currencyID, Account const& accountID,
bool isDstCurrency, Account const& dstAccount)
{
// VFALCO TODO Use Issue here
auto currencyAccount = std::make_pair(currencyID, accountID);
auto it = mPOMap.find (currencyAccount);
@@ -513,7 +511,9 @@ int Pathfinder::getPathsOut (
if (!bFrozen)
{
for (auto const& item : mRLCache->getRippleLines (accountID).getItems ())
count = getApp().getOrderBookDB().getBookSize({currencyID, accountID});
AccountItems& rippleLines = mRLCache->getRippleLines (accountID);
for (auto const& item : rippleLines.getItems ())
{
RippleState* rspEntry = (RippleState*) item.get ();