diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index f7193772c..6a9d732fa 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -6,7 +6,6 @@ #include #include "Application.h" -#include "AccountItems.h" #include "Log.h" SETUP_LOG(); @@ -396,12 +395,6 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax // Last element is for non-XRP, continue by adding ripple lines and order books. // Create new paths for each outbound account not already in the path. - boost::unordered_map::iterator it = aiMap.find(speEnd.mAccountID); - if (it == aiMap.end()) - it = aiMap.insert(std::make_pair(speEnd.mAccountID, - boost::make_shared( - boost::cref(speEnd.mAccountID), boost::cref(mLedger), AccountItem::pointer(new RippleState())))).first; - AccountItems& rippleLines = *it->second; SLE::pointer sleEnd = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(speEnd.mAccountID)); @@ -416,7 +409,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax // True, the cursor requires the next node to be authorized. bool bRequireAuth = isSetBit(sleEnd->getFieldU32(sfFlags), lsfRequireAuth); - BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems()) + BOOST_FOREACH(AccountItem::ref item, getRippleLines(speEnd.mAccountID).getItems()) { RippleState* rspEntry = (RippleState*) item.get(); const uint160& uPeerID = rspEntry->getAccountIDPeer(); @@ -784,6 +777,15 @@ boost::unordered_set usAccountSourceCurrencies(const RippleAddress& raA return usCurrencies; } +AccountItems& Pathfinder::getRippleLines(const uint160& accountID) +{ + boost::unordered_map::iterator it = mRLMap.find(accountID); + if (it == mRLMap.end()) + it = mRLMap.insert(std::make_pair(accountID, boost::make_shared + (boost::cref(accountID), boost::cref(mLedger), AccountItem::pointer(new RippleState())))).first; + return *it->second; +} + bool Pathfinder::matchesOrigin(const uint160& currency, const uint160& issuer) { return (currency == mSrcCurrencyID) && (issuer == mSrcIssuerID); diff --git a/src/cpp/ripple/Pathfinder.h b/src/cpp/ripple/Pathfinder.h index 87f3c9551..de61977b7 100644 --- a/src/cpp/ripple/Pathfinder.h +++ b/src/cpp/ripple/Pathfinder.h @@ -7,6 +7,7 @@ #include "RippleAddress.h" #include "RippleCalc.h" #include "OrderBookDB.h" +#include "AccountItems.h" #if 0 // @@ -47,6 +48,8 @@ class Pathfinder PathState::pointer mPsDefault; LoadEvent::pointer mLoadMonitor; + boost::unordered_map mRLMap; + // std::list mBuildingPaths; // std::list mCompletePaths; @@ -59,6 +62,8 @@ class Pathfinder bool matchesOrigin(const uint160& currency, const uint160& issuer); + AccountItems& getRippleLines(const uint160& accountID); + public: Pathfinder(Ledger::ref ledger, const RippleAddress& srcAccountID, const RippleAddress& dstAccountID,