mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 02:55:50 +00:00
Omit default paths from pathfinder results.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -62,6 +62,7 @@ bool PathState::lessPriority(PathState& lhs, PathState& rhs)
|
||||
// - A node names it's output.
|
||||
// - A ripple nodes output issuer must be the node's account or the next node's account.
|
||||
// - Offers can only go directly to another offer if the currency and issuer are an exact match.
|
||||
// - Real issuers must be specified for non-XRP.
|
||||
TER PathState::pushImply(
|
||||
const uint160& uAccountID, // --> Delivering to this account.
|
||||
const uint160& uCurrencyID, // --> Delivering this currency.
|
||||
@@ -186,6 +187,8 @@ TER PathState::pushNode(
|
||||
else
|
||||
{
|
||||
// Add required intermediate nodes to deliver to current account.
|
||||
cLog(lsDEBUG) << "pushNode: imply for account.";
|
||||
|
||||
terResult = pushImply(
|
||||
pnCur.uAccountID, // Current account.
|
||||
pnCur.uCurrencyID, // Wanted currency.
|
||||
@@ -262,6 +265,7 @@ TER PathState::pushNode(
|
||||
else if (!!pnPrv.uAccountID)
|
||||
{
|
||||
// Previous is an account.
|
||||
cLog(lsDEBUG) << "pushNode: imply for offer.";
|
||||
|
||||
// Insert intermediary issuer account if needed.
|
||||
terResult = pushImply(
|
||||
@@ -364,7 +368,10 @@ cLog(lsDEBUG) << boost::str(boost::format("PathState: sender implied: account=%s
|
||||
BOOST_FOREACH(const STPathElement& speElement, spSourcePath)
|
||||
{
|
||||
if (tesSUCCESS == terStatus)
|
||||
{
|
||||
cLog(lsDEBUG) << boost::str(boost::format("PathState: element in path:"));
|
||||
terStatus = pushNode(speElement.getNodeType(), speElement.getAccountID(), speElement.getCurrency(), speElement.getIssuerID());
|
||||
}
|
||||
}
|
||||
|
||||
const PaymentNode& pnPrv = vpnNodes.back();
|
||||
|
||||
Reference in New Issue
Block a user