From c0049542a2e10dbacc60237ab78748ff815e7c6b Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 8 Apr 2013 17:44:04 -0700 Subject: [PATCH] Correctly handle one-element paths. Don't call setCanonical, it's broken. --- src/cpp/ripple/Pathfinder.cpp | 2 +- src/cpp/ripple/RPCHandler.cpp | 2 +- src/cpp/ripple/RippleCalc.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index f7972951e..bb29edacc 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -72,7 +72,7 @@ static bool bQualityCmp(const path_LQ_t& a, const path_LQ_t&b) // A path is a default path if it is implied via src, dst, send, and sendmax. bool Pathfinder::bDefaultPath(const STPath& spPath) { - if (2 == spPath.mPath.size()) { + if (2 >= spPath.mPath.size()) { // Empty path is a default. Don't need to add it to return set. cLog(lsTRACE) << "findPaths: empty path: direct"; diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index a299c3f07..b43a10ae0 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -1330,7 +1330,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost) // Reuse the expanded as it would need to be calcuated anyway to produce the canonical. // (At least unless we make a direct canonical.) - RippleCalc::setCanonical(spsCanonical, vpsExpanded, false); + // RippleCalc::setCanonical(spsCanonical, vpsExpanded, false); jvEntry["source_amount"] = saMaxAmountAct.getJson(0); // jvEntry["paths_expanded"] = vpsExpanded.getJson(0); diff --git a/src/cpp/ripple/RippleCalc.cpp b/src/cpp/ripple/RippleCalc.cpp index 89eba9d58..359454dbc 100644 --- a/src/cpp/ripple/RippleCalc.cpp +++ b/src/cpp/ripple/RippleCalc.cpp @@ -559,6 +559,7 @@ void PathState::setCanonical( const PathState& psExpanded ) { + assert(false); saInAct = psExpanded.saInAct; saOutAct = psExpanded.saOutAct; @@ -572,7 +573,7 @@ void PathState::setCanonical( unsigned int uEnd = psExpanded.vpnNodes.size(); // The node, indexed by 0, not to include. - uint160 uDstAccountID = psExpanded.vpnNodes[uEnd].uAccountID; + uint160 uDstAccountID = psExpanded.vpnNodes[uEnd].uAccountID; // FIXME: This can't be right uint160 uAccountID = psExpanded.vpnNodes[0].uAccountID; uint160 uCurrencyID = uMaxCurrencyID;