mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix pathfinding mis-setting currency on order book out.
This commit is contained in:
@@ -133,13 +133,15 @@ bool Pathfinder::bDefaultPath(const STPath& spPath)
|
||||
|
||||
// Expand the current path.
|
||||
pspCurrent->setExpanded(lesActive, spPath, mDstAccountID, mSrcAccountID);
|
||||
// XXX Need to report or act on errors returned in pspCurrent->terStatus.
|
||||
|
||||
// Determine if expanded current path is the default.
|
||||
// When path is a default (implied). Don't need to add it to return set.
|
||||
bDefault = pspCurrent->vpnNodes == mPsDefault->vpnNodes;
|
||||
|
||||
cLog(lsTRACE) << "bDefaultPath: expanded path: " << pspCurrent->getJson();
|
||||
cLog(lsTRACE) << "bDefaultPath: default path: indirect: " << spPath.getJson(0);
|
||||
cLog(lsTRACE) << "bDefaultPath: source path: " << spPath.getJson(0);
|
||||
cLog(lsTRACE) << "bDefaultPath: default path: " << mPsDefault->getJson();
|
||||
|
||||
return bDefault;
|
||||
}
|
||||
@@ -384,14 +386,16 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
}
|
||||
else if (!speEnd.mCurrencyID)
|
||||
{
|
||||
// XXX Might restrict the number of times bridging through XRP.
|
||||
|
||||
// Cursor is for XRP, continue with qualifying books: XRP -> non-XRP
|
||||
BOOST_FOREACH(OrderBook::ref book, theApp->getOrderBookDB().getXRPInBooks())
|
||||
{
|
||||
// New end is an order book with the currency and issuer.
|
||||
|
||||
// Don't allow looping through same order books.
|
||||
if (!spPath.hasSeen(ACCOUNT_XRP, book->getCurrencyOut(), book->getIssuerOut()))
|
||||
{
|
||||
// Not a order book already in path.
|
||||
STPath spNew(spPath);
|
||||
STPathElement speBook(ACCOUNT_XRP, book->getCurrencyOut(), book->getIssuerOut());
|
||||
STPathElement speAccount(book->getIssuerOut(), book->getCurrencyOut(), book->getIssuerOut());
|
||||
@@ -401,6 +405,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
|
||||
cLog(lsDEBUG)
|
||||
<< boost::str(boost::format("findPaths: XRP -> %s/%s")
|
||||
// % STAmount::createHumanCurrency(book->getCurrencyOut())
|
||||
// % RippleAddress::createHumanAccountID(book->getIssuerOut())
|
||||
% STAmount::createHumanCurrency(speBook.mCurrencyID)
|
||||
% RippleAddress::createHumanAccountID(speBook.mIssuerID));
|
||||
|
||||
@@ -515,7 +521,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
|
||||
spNew.mPath.push_back(speBook); // Add the order book.
|
||||
|
||||
if (!book->getCurrencyOut())
|
||||
if (!!book->getCurrencyOut())
|
||||
{
|
||||
// For non-XRP out, don't end on the book, add the issuing account.
|
||||
STPathElement speAccount(book->getIssuerOut(), book->getCurrencyOut(), book->getIssuerOut());
|
||||
|
||||
@@ -35,6 +35,55 @@ bool PaymentNode::operator==(const PaymentNode& pnOther) const {
|
||||
&& pnOther.uIssuerID == uIssuerID;
|
||||
}
|
||||
|
||||
// This is for debugging not end users. Output names can be changed without warning.
|
||||
Json::Value PaymentNode::getJson() const
|
||||
{
|
||||
Json::Value jvNode(Json::objectValue);
|
||||
Json::Value jvFlags(Json::arrayValue);
|
||||
|
||||
jvNode["type"] = uFlags;
|
||||
|
||||
if (isSetBit(uFlags, STPathElement::typeAccount) || !!uAccountID)
|
||||
jvFlags.append(!!isSetBit(uFlags, STPathElement::typeAccount) == !!uAccountID ? "account" : "-account");
|
||||
|
||||
if (isSetBit(uFlags, STPathElement::typeCurrency) || !!uCurrencyID)
|
||||
jvFlags.append(!!isSetBit(uFlags, STPathElement::typeCurrency) == !!uCurrencyID ? "currency" : "-currency");
|
||||
|
||||
if (isSetBit(uFlags, STPathElement::typeIssuer) || !!uIssuerID)
|
||||
jvFlags.append(!!isSetBit(uFlags, STPathElement::typeIssuer) == !!uIssuerID ? "issuer" : "-issuer");
|
||||
|
||||
jvNode["flags"] = jvFlags;
|
||||
|
||||
if (!!uAccountID)
|
||||
jvNode["account"] = RippleAddress::createHumanAccountID(uAccountID);
|
||||
|
||||
if (!!uCurrencyID)
|
||||
jvNode["currency"] = STAmount::createHumanCurrency(uCurrencyID);
|
||||
|
||||
if (!!uIssuerID)
|
||||
jvNode["issuer"] = RippleAddress::createHumanAccountID(uIssuerID);
|
||||
|
||||
if (saRevRedeem)
|
||||
jvNode["rev_redeem"] = saRevRedeem.getFullText();
|
||||
|
||||
if (saRevIssue)
|
||||
jvNode["rev_issue"] = saRevIssue.getFullText();
|
||||
|
||||
if (saRevDeliver)
|
||||
jvNode["rev_deliver"] = saRevDeliver.getFullText();
|
||||
|
||||
if (saFwdRedeem)
|
||||
jvNode["fwd_redeem"] = saFwdRedeem.getFullText();
|
||||
|
||||
if (saFwdIssue)
|
||||
jvNode["fwd_issue"] = saFwdIssue.getFullText();
|
||||
|
||||
if (saFwdDeliver)
|
||||
jvNode["fwd_deliver"] = saFwdDeliver.getFullText();
|
||||
|
||||
return jvNode;
|
||||
}
|
||||
|
||||
//
|
||||
// PathState implementation
|
||||
//
|
||||
@@ -273,7 +322,9 @@ TER PathState::pushNode(
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
vpnNodes.push_back(pnCur);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -311,6 +362,7 @@ TER PathState::pushNode(
|
||||
vpnNodes.push_back(pnCur);
|
||||
}
|
||||
}
|
||||
|
||||
cLog(lsTRACE) << boost::str(boost::format("pushNode< : %s") % transToken(terResult));
|
||||
|
||||
return terResult;
|
||||
@@ -335,7 +387,7 @@ void PathState::setExpanded(
|
||||
const uint160 uOutIssuerID = saOutReq.getIssuer();
|
||||
const uint160 uSenderIssuerID = !!uMaxCurrencyID ? uSenderID : ACCOUNT_XRP; // Sender is always issuer for non-XRP.
|
||||
|
||||
// cLog(lsDEBUG) << boost::str(boost::format("setExpanded>"));
|
||||
cLog(lsDEBUG) << boost::str(boost::format("setExpanded> %s") % spSourcePath.getJson(0));
|
||||
|
||||
lesEntries = lesSource.duplicate();
|
||||
|
||||
@@ -732,43 +784,7 @@ Json::Value PathState::getJson() const
|
||||
|
||||
BOOST_FOREACH(const PaymentNode& pnNode, vpnNodes)
|
||||
{
|
||||
Json::Value jvNode(Json::objectValue);
|
||||
|
||||
Json::Value jvFlags(Json::arrayValue);
|
||||
|
||||
if (pnNode.uFlags & STPathElement::typeAccount)
|
||||
jvFlags.append("account");
|
||||
|
||||
jvNode["flags"] = jvFlags;
|
||||
|
||||
if (pnNode.uFlags & STPathElement::typeAccount)
|
||||
jvNode["account"] = RippleAddress::createHumanAccountID(pnNode.uAccountID);
|
||||
|
||||
if (!!pnNode.uCurrencyID)
|
||||
jvNode["currency"] = STAmount::createHumanCurrency(pnNode.uCurrencyID);
|
||||
|
||||
if (!!pnNode.uIssuerID)
|
||||
jvNode["issuer"] = RippleAddress::createHumanAccountID(pnNode.uIssuerID);
|
||||
|
||||
if (pnNode.saRevRedeem)
|
||||
jvNode["rev_redeem"] = pnNode.saRevRedeem.getFullText();
|
||||
|
||||
if (pnNode.saRevIssue)
|
||||
jvNode["rev_issue"] = pnNode.saRevIssue.getFullText();
|
||||
|
||||
if (pnNode.saRevDeliver)
|
||||
jvNode["rev_deliver"] = pnNode.saRevDeliver.getFullText();
|
||||
|
||||
if (pnNode.saFwdRedeem)
|
||||
jvNode["fwd_redeem"] = pnNode.saFwdRedeem.getFullText();
|
||||
|
||||
if (pnNode.saFwdIssue)
|
||||
jvNode["fwd_issue"] = pnNode.saFwdIssue.getFullText();
|
||||
|
||||
if (pnNode.saFwdDeliver)
|
||||
jvNode["fwd_deliver"] = pnNode.saFwdDeliver.getFullText();
|
||||
|
||||
jvNodes.append(jvNode);
|
||||
jvNodes.append(pnNode.getJson());
|
||||
}
|
||||
|
||||
jvPathState["status"] = terStatus;
|
||||
|
||||
@@ -56,6 +56,8 @@ protected:
|
||||
|
||||
public:
|
||||
bool operator==(const PaymentNode& pnOther) const;
|
||||
|
||||
Json::Value getJson() const;
|
||||
};
|
||||
|
||||
// account id, currency id, issuer id :: node
|
||||
|
||||
Reference in New Issue
Block a user