mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
When pathfinding, don't output a redundant account node
This commit is contained in:
@@ -1086,20 +1086,31 @@ void Pathfinder::addLink (
|
||||
book->getIssuerOut (),
|
||||
book->getCurrencyOut (),
|
||||
book->getIssuerOut ()))
|
||||
{ // Don't want the book if we've already seen the issuer
|
||||
// add the order book itself
|
||||
newPath.emplace_back (
|
||||
STPathElement::typeCurrency |
|
||||
STPathElement::typeIssuer,
|
||||
xrpAccount (),
|
||||
book->getCurrencyOut (),
|
||||
book->getIssuerOut ());
|
||||
|
||||
if (book->getIssuerOut () == mDstAccount &&
|
||||
book->getCurrencyOut () == mDstAmount.getCurrency())
|
||||
{
|
||||
// Don't want the book if we've already seen the issuer
|
||||
// book -> account -> book
|
||||
if ((newPath.size() >= 2) &&
|
||||
(newPath.back().isAccount ()) &&
|
||||
(newPath[newPath.size() - 2].isOffer ()))
|
||||
{
|
||||
// with the destination account, this path is
|
||||
// complete
|
||||
// replace the redundant account with the order book
|
||||
newPath[newPath.size() - 1] = STPathElement (
|
||||
STPathElement::typeCurrency | STPathElement::typeIssuer,
|
||||
xrpAccount(), book->getCurrencyOut(),
|
||||
book->getIssuerOut());
|
||||
}
|
||||
else
|
||||
{
|
||||
// add the order book
|
||||
newPath.emplace_back(
|
||||
STPathElement::typeCurrency | STPathElement::typeIssuer,
|
||||
xrpAccount(), book->getCurrencyOut(),
|
||||
book->getIssuerOut());
|
||||
}
|
||||
|
||||
if (book->getIssuerOut() == mDstAccount &&
|
||||
book->getCurrencyOut() == mDstAmount.getCurrency())
|
||||
{ // with the destination account, this path is complete
|
||||
WriteLog (lsTRACE, Pathfinder)
|
||||
<< "complete path found ba: "
|
||||
<< currentPath.getJson(0);
|
||||
|
||||
@@ -195,6 +195,16 @@ public:
|
||||
return mPath.front ();
|
||||
}
|
||||
|
||||
STPathElement& operator[](int i)
|
||||
{
|
||||
return mPath[i];
|
||||
}
|
||||
|
||||
const STPathElement& operator[](int i) const
|
||||
{
|
||||
return mPath[i];
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<STPathElement> mPath;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user