Clean OrderBookDB::getBooksBy methods.

This commit is contained in:
Tom Ritchford
2014-07-29 14:34:09 -04:00
committed by Vinnie Falco
parent 0f409b7bec
commit 4b905fe9ff
3 changed files with 6 additions and 25 deletions

View File

@@ -166,37 +166,19 @@ void OrderBookDB::addOrderBook(Book const& book)
}
// return list of all orderbooks that want this issuerID and currencyID
void OrderBookDB::getBooksByTakerPays (
Issue const& issue, OrderBook::List& bookRet)
OrderBook::List OrderBookDB::getBooksByTakerPays (Issue const& issue)
{
ScopedLockType sl (mLock);
auto it = mSourceMap.find (issue);
if (it != mSourceMap.end ())
bookRet = it->second;
else
bookRet.clear ();
return it == mSourceMap.end () ? OrderBook::List() : it->second;
}
bool OrderBookDB::isBookToXRP(Issue const& issue)
{
ScopedLockType sl (mLock);
return mXRPBooks.count(issue) > 0;
}
// return list of all orderbooks that give this issuerID and currencyID
void OrderBookDB::getBooksByTakerGets (
Issue const& issue, OrderBook::List& bookRet)
{
ScopedLockType sl (mLock);
auto it = mDestMap.find (issue);
if (it != mDestMap.end ())
bookRet = it->second;
else
bookRet.clear ();
}
BookListeners::pointer OrderBookDB::makeBookListeners (Book const& book)
{
ScopedLockType sl (mLock);

View File

@@ -38,8 +38,7 @@ public:
void addOrderBook(Book const&);
// return list of all orderbooks that want this issuerID and currencyID
void getBooksByTakerPays (Issue const&, OrderBook::List&);
void getBooksByTakerGets (Issue const&, OrderBook::List&);
OrderBook::List getBooksByTakerPays (Issue const&);
bool isBookToXRP (Issue const&);

View File

@@ -822,11 +822,11 @@ void Pathfinder::addLink(
else
{
bool bDestOnly = (addFlags & afOB_LAST) != 0;
std::vector<OrderBook::pointer> books;
getApp().getOrderBookDB().getBooksByTakerPays(
{uEndCurrency, uEndIssuer}, books);
auto books = getApp().getOrderBookDB().getBooksByTakerPays(
{uEndCurrency, uEndIssuer});
WriteLog (lsTRACE, Pathfinder)
<< books.size() << " books found from this currency/issuer";
for (auto const& book : books)
{
if (!currentPath.hasSeen (