diff --git a/rippled-example.cfg b/rippled-example.cfg index 2b04f763b..638a383ac 100644 --- a/rippled-example.cfg +++ b/rippled-example.cfg @@ -251,7 +251,7 @@ # When searching for paths, the maximum number of nodes allowed. This can take # exponentially more resources as the size is increased. # -# The default is: 5 +# The default is: 4 # # [rpc_startup] # Specify a list of RPC commands to run at startup. diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index f3134e904..323d2d22e 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -118,7 +118,7 @@ bool Pathfinder::bDefaultPath(const STPath& spPath) } typedef std::pair candidate_t; -bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second) +static bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second) { if (first.first < second.first) return false; @@ -127,6 +127,17 @@ bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second) return (first.first ^ seq) < (second.first ^ seq); } +static int getEffectiveLength(const STPath& spPath) +{ // don't count exchanges to non-XRP currencies twice (only count the forced issuer account node) + int length = 0; + for (std::vector::const_iterator it = spPath.begin(); it != spPath.end(); ++it) + { + if (it->isAccount() || it->getCurrency().isZero()) + ++length; + } + return length; +} + Pathfinder::Pathfinder(Ledger::ref ledger, const RippleAddress& uSrcAccountID, const RippleAddress& uDstAccountID, const uint160& uSrcCurrencyID, const uint160& uSrcIssuerID, const STAmount& saDstAmount, bool& bValid) @@ -360,7 +371,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax % STAmount::createHumanCurrency(speEnd.mCurrencyID) % RippleAddress::createHumanAccountID(speEnd.mIssuerID)); - if (spPath.mPath.size() >= iMaxSteps) + int length = getEffectiveLength(spPath.mPath); + if (length >= iMaxSteps) { // Path is at maximum size. Don't want to add more. @@ -369,12 +381,10 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax continue; } - bool isLast = (spPath.mPath.size() == (iMaxSteps - 1)); + bool isLast = (length == (iMaxSteps - 1)); if (!speEnd.mCurrencyID) { - // XXX Might restrict the number of times bridging through XRP. - // Cursor is for XRP, continue with qualifying books: XRP -> non-XRP std::vector xrpBooks; theApp->getOrderBookDB().getBooksByTakerPays(ACCOUNT_XRP, CURRENCY_XRP, xrpBooks);