From 9f1c97526862fa252a3c92bf7b87cc4fc9097297 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 9 Apr 2013 00:43:22 -0700 Subject: [PATCH] Include XRP in usAccountSourceCurrencies so that it can't get included twice. --- src/cpp/ripple/Pathfinder.cpp | 7 ++++++- src/cpp/ripple/Pathfinder.h | 3 ++- src/cpp/ripple/RPCHandler.cpp | 6 +----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index 6682a22dd..c9c9f168f 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -800,10 +800,15 @@ void Pathfinder::addPathOption(PathOption::pointer pathOption) } #endif -boost::unordered_set usAccountSourceCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger) +boost::unordered_set usAccountSourceCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger, + bool includeXRP) { boost::unordered_set usCurrencies; + // YYY Only bother if they are above reserve + if (includeXRP) + usCurrencies.insert(uint160(CURRENCY_XRP)); + // List of ripple lines. AccountItems rippleLines(raAccountID.getAccountID(), lrLedger, AccountItem::pointer(new RippleState())); diff --git a/src/cpp/ripple/Pathfinder.h b/src/cpp/ripple/Pathfinder.h index dc170ecb2..1f723f562 100644 --- a/src/cpp/ripple/Pathfinder.h +++ b/src/cpp/ripple/Pathfinder.h @@ -78,7 +78,8 @@ public: bool bDefaultPath(const STPath& spPath); }; -boost::unordered_set usAccountSourceCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger); +boost::unordered_set usAccountSourceCurrencies(const RippleAddress& raAccountID, Ledger::ref lrLedger, + bool includeXRP); #endif // vim:ts=4 diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index d779c10b4..70eeefd6d 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -1215,11 +1215,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost) } else { - boost::unordered_set usCurrencies = usAccountSourceCurrencies(raSrc, lpLedger); - - // Add XRP as a source currency. - // YYY Only bother if they are above reserve. - usCurrencies.insert(uint160(CURRENCY_XRP)); + boost::unordered_set usCurrencies = usAccountSourceCurrencies(raSrc, lpLedger, true); jvSrcCurrencies = Json::Value(Json::arrayValue);