diff --git a/src/cpp/ripple/AccountItems.h b/src/cpp/ripple/AccountItems.h index 3382dff265..f72e9f558a 100644 --- a/src/cpp/ripple/AccountItems.h +++ b/src/cpp/ripple/AccountItems.h @@ -35,6 +35,7 @@ class AccountItems void fillItems(const uint160& accountID, Ledger::ref ledger); public: + typedef boost::shared_ptr pointer; AccountItems(const uint160& accountID, Ledger::ref ledger, AccountItem::pointer ofType); diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index 1be85e3d4b..fbcd7ce3e2 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -205,6 +205,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax } LedgerEntrySet lesActive(mLedger); + boost::unordered_map aiMap; SLE::pointer sleSrc = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mSrcAccountID)); if (!sleSrc) @@ -285,7 +286,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax continue; } - if (tLog(lsTRACE) + if (sLog(lsTRACE)) { cLog(lsTRACE) << "findPaths: finish? account: " << (speEnd.mAccountID == mDstAccountID); cLog(lsTRACE) << "findPaths: finish? currency: " << (speEnd.mCurrencyID == mDstAmount.getCurrency()); @@ -387,7 +388,13 @@ 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. - AccountItems rippleLines(speEnd.mAccountID, mLedger, AccountItem::pointer(new RippleState())); + 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)); tLog(!sleEnd, lsDEBUG) @@ -403,7 +410,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems()) { RippleState* rspEntry = (RippleState*) item.get(); - const uint160 uPeerID = rspEntry->getAccountIDPeer().getAccountID(); + const uint160 uPeerID = rspEntry->getAccountIDPeer(); if (spPath.hasSeen(uPeerID, speEnd.mCurrencyID, uPeerID)) { diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index be26949a61..0e7b9a949a 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -929,7 +929,7 @@ Json::Value RPCHandler::doAccountLines(Json::Value jvRequest) Json::Value jPeer = Json::Value(Json::objectValue); - jPeer["account"] = line->getAccountIDPeer().humanAccountID(); + jPeer["account"] = RippleAddress::createHumanAccountID(line->getAccountIDPeer()); // Amount reported is positive if current account holds other account's IOUs. // Amount reported is negative if other account holds current account's IOUs. jPeer["balance"] = saBalance.getText(); diff --git a/src/cpp/ripple/RippleCalc.cpp b/src/cpp/ripple/RippleCalc.cpp index a6fa7d7440..3ec5f8b578 100644 --- a/src/cpp/ripple/RippleCalc.cpp +++ b/src/cpp/ripple/RippleCalc.cpp @@ -2521,7 +2521,7 @@ cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: Build direct: status: %s" } } - cLog(lsINFO) << "rippleCalc: Paths in set: " << spsPaths.size(); + cLog(lsTRACE) << "rippleCalc: Paths in set: " << spsPaths.size(); int iIndex = 0; BOOST_FOREACH(const STPath& spPath, spsPaths) diff --git a/src/cpp/ripple/RippleState.cpp b/src/cpp/ripple/RippleState.cpp index 1ec6ebdaf8..65facb7f11 100644 --- a/src/cpp/ripple/RippleState.cpp +++ b/src/cpp/ripple/RippleState.cpp @@ -19,8 +19,8 @@ RippleState::RippleState(SerializedLedgerEntry::ref ledgerEntry) : AccountItem(l mLowLimit = mLedgerEntry->getFieldAmount(sfLowLimit); mHighLimit = mLedgerEntry->getFieldAmount(sfHighLimit); - mLowID = RippleAddress::createAccountID(mLowLimit.getIssuer()); - mHighID = RippleAddress::createAccountID(mHighLimit.getIssuer()); + mLowID = mLowLimit.getIssuer(); + mHighID = mHighLimit.getIssuer(); mLowQualityIn = mLedgerEntry->getFieldU32(sfLowQualityIn); mLowQualityOut = mLedgerEntry->getFieldU32(sfLowQualityOut); @@ -35,7 +35,7 @@ RippleState::RippleState(SerializedLedgerEntry::ref ledgerEntry) : AccountItem(l void RippleState::setViewAccount(const uint160& accountID) { - bool bViewLowestNew = mLowID.getAccountID() == accountID; + bool bViewLowestNew = mLowID == accountID; if (bViewLowestNew != mViewLowest) { diff --git a/src/cpp/ripple/RippleState.h b/src/cpp/ripple/RippleState.h index ac79673368..df8b7fdc56 100644 --- a/src/cpp/ripple/RippleState.h +++ b/src/cpp/ripple/RippleState.h @@ -19,8 +19,8 @@ public: private: uint32 mFlags; - RippleAddress mLowID; - RippleAddress mHighID; + uint160 mLowID; + uint160 mHighID; STAmount mLowLimit; STAmount mHighLimit; @@ -44,8 +44,8 @@ public: void setViewAccount(const uint160& accountID); - const RippleAddress getAccountID() const { return mViewLowest ? mLowID : mHighID; } - const RippleAddress getAccountIDPeer() const { return !mViewLowest ? mLowID : mHighID; } + const uint160& getAccountID() const { return mViewLowest ? mLowID : mHighID; } + const uint160& getAccountIDPeer() const { return !mViewLowest ? mLowID : mHighID; } bool getAuth() const { return isSetBit(mFlags, mViewLowest ? lsfLowAuth : lsfHighAuth); } bool getAuthPeer() const { return isSetBit(mFlags, !mViewLowest ? lsfLowAuth : lsfHighAuth); } diff --git a/src/cpp/ripple/SHAMap.cpp b/src/cpp/ripple/SHAMap.cpp index 77051f17ff..89874875af 100644 --- a/src/cpp/ripple/SHAMap.cpp +++ b/src/cpp/ripple/SHAMap.cpp @@ -194,7 +194,8 @@ SHAMapTreeNode* SHAMap::walkToPointer(const uint256& id) { int branch = inNode->selectBranch(id); const uint256& nextHash = inNode->getChildHash(branch); - if (nextHash.isZero()) return NULL; + if (nextHash.isZero()) + return NULL; inNode = getNodePointer(inNode->getChildNodeID(branch), nextHash); assert(inNode); }