From 6d9a27e593ebdd6de10356cab694ca7033a3aaee Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 7 Apr 2013 23:55:54 -0700 Subject: [PATCH] Count a path to the destination extra. --- src/cpp/ripple/Pathfinder.cpp | 7 +++++-- src/cpp/ripple/Pathfinder.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cpp/ripple/Pathfinder.cpp b/src/cpp/ripple/Pathfinder.cpp index 1118a2fb6..502ed9fbc 100644 --- a/src/cpp/ripple/Pathfinder.cpp +++ b/src/cpp/ripple/Pathfinder.cpp @@ -468,7 +468,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax } else { // save this candidate - int paths_out = getPathsOut(speEnd.mCurrencyID, uPeerID); + int paths_out = getPathsOut(speEnd.mCurrencyID, uPeerID, dstCurrency, mDstAccountID); if (paths_out != 0) candidates.push_back(std::make_pair(paths_out, uPeerID)); } @@ -831,7 +831,8 @@ bool Pathfinder::matchesOrigin(const uint160& currency, const uint160& issuer) return (currency == mSrcCurrencyID) && (issuer == mSrcIssuerID); } -int Pathfinder::getPathsOut(const uint160& currencyID, const uint160& accountID) +int Pathfinder::getPathsOut(const uint160& currencyID, const uint160& accountID, + bool isDstCurrency, const uint160& dstAccount) { std::pair accountCurrency(currencyID, accountID); boost::unordered_map, int>::iterator it = mPOMap.find(accountCurrency); @@ -847,6 +848,8 @@ int Pathfinder::getPathsOut(const uint160& currencyID, const uint160& accountID) nothing(); else if (!rspEntry->getBalance().isPositive() && !rspEntry->getLimitPeer().isPositive()) // no credit nothing(); + else if (isDstCurrency && (dstAccount == rspEntry->getAccountIDPeer())) + count += 10; // count a path to the destination extra else ++count; } diff --git a/src/cpp/ripple/Pathfinder.h b/src/cpp/ripple/Pathfinder.h index 5e1e9a0e1..d82b250e3 100644 --- a/src/cpp/ripple/Pathfinder.h +++ b/src/cpp/ripple/Pathfinder.h @@ -65,7 +65,7 @@ class Pathfinder AccountItems& getRippleLines(const uint160& accountID); - int getPathsOut(const uint160& currency, const uint160& accountID); + int getPathsOut(const uint160& currency, const uint160& accountID, bool isDestCurrency, const uint160& dest); public: Pathfinder(Ledger::ref ledger,