mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
Fixes for brute force path finding.
This commit is contained in:
@@ -339,7 +339,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
% STAmount::createHumanCurrency(speEnd.mCurrencyID)
|
||||
% RippleAddress::createHumanAccountID(speEnd.mIssuerID));
|
||||
|
||||
if (spPath.mPath.size() == iMaxSteps)
|
||||
if (spPath.mPath.size() >= iMaxSteps)
|
||||
{
|
||||
// Path is at maximum size. Don't want to add more.
|
||||
|
||||
@@ -365,8 +365,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
spNew.mPath.push_back(speBook); // Add the order book.
|
||||
spNew.mPath.push_back(speAccount); // Add the account and currency
|
||||
|
||||
cLog(lsDEBUG) <<
|
||||
boost::str(boost::format("findPaths: XRP -> %s/%s")
|
||||
cLog(lsDEBUG)
|
||||
<< boost::str(boost::format("findPaths: XRP -> %s/%s")
|
||||
% STAmount::createHumanCurrency(speBook.mCurrencyID)
|
||||
% RippleAddress::createHumanAccountID(speBook.mIssuerID));
|
||||
|
||||
@@ -387,10 +387,14 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
AccountItems rippleLines(speEnd.mAccountID, mLedger, AccountItem::pointer(new RippleState()));
|
||||
SLE::pointer sleEnd = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(speEnd.mAccountID));
|
||||
|
||||
tLog(sleEnd, lsDEBUG)
|
||||
<< boost::str(boost::format("findPaths: account without root: %s")
|
||||
% RippleAddress::createHumanAccountID(speEnd.mAccountID));
|
||||
tLog(!sleEnd, lsDEBUG)
|
||||
<< boost::str(boost::format("findPaths: order book: %s/%s : ")
|
||||
% RippleAddress::createHumanAccountID(speEnd.mAccountID)
|
||||
% RippleAddress::createHumanAccountID(speEnd.mIssuerID));
|
||||
|
||||
if (sleEnd)
|
||||
{
|
||||
// On a non-XRP account:
|
||||
bool bRequireAuth = isSetBit(sleEnd->getFieldU32(sfFlags), lsfRequireAuth);
|
||||
|
||||
BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
|
||||
@@ -440,11 +444,11 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
% RippleAddress::createHumanAccountID(uPeerID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Every book that wants the source currency.
|
||||
std::vector<OrderBook::pointer> books;
|
||||
|
||||
|
||||
theApp->getOrderBookDB().getBooks(speEnd.mIssuerID, speEnd.mCurrencyID, books);
|
||||
|
||||
BOOST_FOREACH(OrderBook::ref book, books)
|
||||
@@ -455,7 +459,15 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
STPath spNew(spPath);
|
||||
STPathElement speBook(ACCOUNT_XRP, book->getCurrencyOut(), book->getIssuerOut());
|
||||
|
||||
spNew.mPath.push_back(speBook);
|
||||
spNew.mPath.push_back(speBook); // Add the order book.
|
||||
|
||||
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());
|
||||
spNew.mPath.push_back(speAccount); // Add the account and currency
|
||||
}
|
||||
|
||||
qspExplore.push(spNew);
|
||||
|
||||
bContinued = true;
|
||||
|
||||
Reference in New Issue
Block a user