From 4b905fe9ff4e7ff0f9eeb468400b64154287380a Mon Sep 17 00:00:00 2001 From: Tom Ritchford Date: Tue, 29 Jul 2014 14:34:09 -0400 Subject: [PATCH] Clean OrderBookDB::getBooksBy methods. --- src/ripple/module/app/ledger/OrderBookDB.cpp | 22 ++------------------ src/ripple/module/app/ledger/OrderBookDB.h | 3 +-- src/ripple/module/app/paths/Pathfinder.cpp | 6 +++--- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/ripple/module/app/ledger/OrderBookDB.cpp b/src/ripple/module/app/ledger/OrderBookDB.cpp index 9721f86bc..b35546c58 100644 --- a/src/ripple/module/app/ledger/OrderBookDB.cpp +++ b/src/ripple/module/app/ledger/OrderBookDB.cpp @@ -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); diff --git a/src/ripple/module/app/ledger/OrderBookDB.h b/src/ripple/module/app/ledger/OrderBookDB.h index 96bf16c72..d3154a5d8 100644 --- a/src/ripple/module/app/ledger/OrderBookDB.h +++ b/src/ripple/module/app/ledger/OrderBookDB.h @@ -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&); diff --git a/src/ripple/module/app/paths/Pathfinder.cpp b/src/ripple/module/app/paths/Pathfinder.cpp index 599f221fd..2f4683f30 100644 --- a/src/ripple/module/app/paths/Pathfinder.cpp +++ b/src/ripple/module/app/paths/Pathfinder.cpp @@ -822,11 +822,11 @@ void Pathfinder::addLink( else { bool bDestOnly = (addFlags & afOB_LAST) != 0; - std::vector 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 (