diff --git a/src/cpp/ripple/AccountItems.cpp b/src/cpp/ripple/AccountItems.cpp index ba8b45c70b..1953ff22d9 100644 --- a/src/cpp/ripple/AccountItems.cpp +++ b/src/cpp/ripple/AccountItems.cpp @@ -14,15 +14,9 @@ AccountItem::AccountItem(SerializedLedgerEntry::ref ledger) : mLedgerEntry(ledge AccountItems::AccountItems(const uint160& accountID, Ledger::ref ledger, AccountItem::pointer ofType) { - mOfType=ofType; - fillItems(accountID, ledger); -} + mOfType = ofType; -// looks in the current ledger -AccountItems::AccountItems(const uint160& accountID, AccountItem::pointer ofType ) -{ - mOfType=ofType; - fillItems(accountID,theApp->getLedgerMaster().getClosedLedger()); + fillItems(accountID, ledger); } void AccountItems::fillItems(const uint160& accountID, Ledger::ref ledger) diff --git a/src/cpp/ripple/AccountItems.h b/src/cpp/ripple/AccountItems.h index 8f9e373f9e..fc4afe7c7b 100644 --- a/src/cpp/ripple/AccountItems.h +++ b/src/cpp/ripple/AccountItems.h @@ -37,7 +37,6 @@ class AccountItems public: AccountItems(const uint160& accountID, Ledger::ref ledger, AccountItem::pointer ofType); - AccountItems(const uint160& accountID, AccountItem::pointer ofType ); // looks in the current ledger std::vector& getItems() { return(mItems); } }; diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index 3a0bd05484..7dcc5ef1b6 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -256,7 +256,7 @@ bool Pathfinder::findPaths(int maxSearchSteps, int maxPay, STPathSet& retPathSet // 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(ele.mAccountID, AccountItem::pointer(new RippleState())); + AccountItems rippleLines(ele.mAccountID, mLedger, AccountItem::pointer(new RippleState())); BOOST_FOREACH(AccountItem::pointer item, rippleLines.getItems()) { diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index 734b45c88d..0fdc086086 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -559,7 +559,7 @@ Json::Value RPCHandler::doAccountLines(Json::Value jvRequest) // XXX This is wrong, we do access the current ledger and do need to worry about changes. // We access a committed ledger and need not worry about changes. - AccountItems rippleLines(raAccount.getAccountID(), AccountItem::pointer(new RippleState())); + AccountItems rippleLines(raAccount.getAccountID(), lpLedger, AccountItem::pointer(new RippleState())); BOOST_FOREACH(AccountItem::pointer item, rippleLines.getItems()) { @@ -629,7 +629,7 @@ Json::Value RPCHandler::doAccountOffers(Json::Value jvRequest) { Json::Value jsonLines(Json::arrayValue); - AccountItems offers(raAccount.getAccountID(), AccountItem::pointer(new Offer())); + AccountItems offers(raAccount.getAccountID(), lpLedger, AccountItem::pointer(new Offer())); BOOST_FOREACH(AccountItem::pointer item, offers.getItems()) { Offer* offer=(Offer*)item.get(); @@ -827,7 +827,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest) RippleCalc::setCanonical(spsCanonical, vpsExpanded); jvEntry["source_amount"] = saMaxAmountAct.getJson(0); -// jvEntry["paths_expanded"] = spsExpanded.getJson(0); +// jvEntry["paths_expanded"] = vpsExpanded.getJson(0); jvEntry["paths_canonical"] = spsCanonical.getJson(0); jvArray.append(jvEntry); diff --git a/src/cpp/ripple/RippleCalc.cpp b/src/cpp/ripple/RippleCalc.cpp index 7847b949c0..6811375535 100644 --- a/src/cpp/ripple/RippleCalc.cpp +++ b/src/cpp/ripple/RippleCalc.cpp @@ -470,9 +470,10 @@ void PathState::setCanonical( // saInAct // - currency is always the same as vpnNodes[0]. - if (uMaxIssuerID != uAccountID); + if (uNode != uEnd && uMaxIssuerID != uAccountID) { // saInAct issuer is not the sender. This forces an implied node. + // cLog(lsDEBUG) << boost::str(boost::format("setCanonical: in diff: uNode=%d uEnd=%d") % uNode % uEnd); // skip node 1 @@ -483,6 +484,7 @@ void PathState::setCanonical( if (uNode != uEnd && !!uOutCurrencyID && uOutIssuerID != uDstAccountID) { + // cLog(lsDEBUG) << boost::str(boost::format("setCanonical: out diff: uNode=%d uEnd=%d") % uNode % uEnd); // The next to last node is saOutAct if an issuer different from receiver is supplied. // The next to last node can be implied. @@ -495,19 +497,21 @@ void PathState::setCanonical( && !pnEnd.uAccountID && pnEnd.uCurrencyID == uOutCurrencyID && pnEnd.uIssuerID == uOutIssuerID) { // The current end node is an offer converting to saOutAct's currency and issuer and can be implied. + // cLog(lsDEBUG) << boost::str(boost::format("setCanonical: out offer: uNode=%d uEnd=%d") % uNode % uEnd); + --uEnd; } // Do not include uEnd. for (; uNode != uEnd; ++uNode) { + // cLog(lsDEBUG) << boost::str(boost::format("setCanonical: loop: uNode=%d uEnd=%d") % uNode % uEnd); const PaymentNode& pnPrv = psExpanded.vpnNodes[uNode-1]; const PaymentNode& pnCur = psExpanded.vpnNodes[uNode]; const PaymentNode& pnNxt = psExpanded.vpnNodes[uNode+1]; const bool bPrvAccount = isSetBit(pnPrv.uFlags, STPathElement::typeAccount); const bool bCurAccount = isSetBit(pnCur.uFlags, STPathElement::typeAccount); - const bool bNxtAccount = isSetBit(pnNxt.uFlags, STPathElement::typeAccount); bool bSkip = false; @@ -525,6 +529,7 @@ void PathState::setCanonical( else { // Currently at an offer. + const bool bNxtAccount = isSetBit(pnNxt.uFlags, STPathElement::typeAccount); if (bPrvAccount && bNxtAccount // Offer surrounded by accounts. && pnPrv.uCurrencyID != pnNxt.uCurrencyID)