Omit default paths from pathfinder results.

This commit is contained in:
Arthur Britto
2012-12-11 14:03:32 -08:00
parent 42e3453073
commit a1915bd899
2 changed files with 32 additions and 11 deletions

View File

@@ -77,7 +77,6 @@ PathOption::PathOption(PathOption::pointer other)
// Return true, if path is a default path with an element.
// A path is a default path if it is implied via src, dst, send, and sendmax.
// XXX Could be determined via STAmount
bool Pathfinder::bDefaultPath(const STPath& spPath)
{
if (2 == spPath.mPath.size()) {
@@ -87,6 +86,15 @@ bool Pathfinder::bDefaultPath(const STPath& spPath)
return true;
}
if (!mPsDefault)
{
// No default path.
// There might not be a direct credit line or there may be no implied nodes
// in send and sendmax.
return false; // Didn't generate a default path. So can't match.
}
PathState::pointer pspCurrent = boost::make_shared<PathState>(mDstAmount, mSrcAmount, mLedger);
if (pspCurrent)
@@ -98,6 +106,8 @@ bool Pathfinder::bDefaultPath(const STPath& spPath)
bDefault = pspCurrent->vpnNodes == mPsDefault->vpnNodes;
cLog(lsDEBUG) << "findPaths: expanded path: " << pspCurrent->getJson();
// Path is a default (implied). Don't need to add it to return set.
cLog(lsDEBUG) << "findPaths: default path: indirect: " << spPath.getJson(0);
@@ -119,13 +129,23 @@ Pathfinder::Pathfinder(const RippleAddress& uSrcAccountID, const RippleAddress&
// Construct the default path for later comparison.
mPsDefault = boost::make_shared<PathState>(mDstAmount, mSrcAmount, mLedger);
PathState::pointer psDefault = boost::make_shared<PathState>(mDstAmount, mSrcAmount, mLedger);
if (mPsDefault)
if (psDefault)
{
LedgerEntrySet lesActive(mLedger);
mPsDefault->setExpanded(lesActive, STPath(), mDstAccountID, mSrcAccountID);
psDefault->setExpanded(lesActive, STPath(), mDstAccountID, mSrcAccountID);
if (tesSUCCESS == psDefault->terStatus)
{
cLog(lsDEBUG) << "Pathfinder: reference path: " << psDefault->getJson();
mPsDefault = psDefault;
}
else
{
cLog(lsDEBUG) << "Pathfinder: reference path: NONE: " << transToken(psDefault->terStatus);
}
}
}
@@ -150,13 +170,7 @@ bool Pathfinder::findPaths(int maxSearchSteps, int maxPay, STPathSet& retPathSet
% RippleAddress::createHumanAccountID(mSrcIssuerID)
);
if (!mPsDefault)
{
cLog(lsDEBUG) << boost::str(boost::format("findPaths: failed to generate default path."));
return false;
}
else if (mLedger)
if (mLedger)
{
std::queue<STPath> pqueue;
STPathElement ele(mSrcAccountID,