mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 13:05:53 +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)
|
% STAmount::createHumanCurrency(speEnd.mCurrencyID)
|
||||||
% RippleAddress::createHumanAccountID(speEnd.mIssuerID));
|
% 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.
|
// 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(speBook); // Add the order book.
|
||||||
spNew.mPath.push_back(speAccount); // Add the account and currency
|
spNew.mPath.push_back(speAccount); // Add the account and currency
|
||||||
|
|
||||||
cLog(lsDEBUG) <<
|
cLog(lsDEBUG)
|
||||||
boost::str(boost::format("findPaths: XRP -> %s/%s")
|
<< boost::str(boost::format("findPaths: XRP -> %s/%s")
|
||||||
% STAmount::createHumanCurrency(speBook.mCurrencyID)
|
% STAmount::createHumanCurrency(speBook.mCurrencyID)
|
||||||
% RippleAddress::createHumanAccountID(speBook.mIssuerID));
|
% 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()));
|
AccountItems rippleLines(speEnd.mAccountID, mLedger, AccountItem::pointer(new RippleState()));
|
||||||
SLE::pointer sleEnd = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(speEnd.mAccountID));
|
SLE::pointer sleEnd = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(speEnd.mAccountID));
|
||||||
|
|
||||||
tLog(sleEnd, lsDEBUG)
|
tLog(!sleEnd, lsDEBUG)
|
||||||
<< boost::str(boost::format("findPaths: account without root: %s")
|
<< boost::str(boost::format("findPaths: order book: %s/%s : ")
|
||||||
% RippleAddress::createHumanAccountID(speEnd.mAccountID));
|
% RippleAddress::createHumanAccountID(speEnd.mAccountID)
|
||||||
|
% RippleAddress::createHumanAccountID(speEnd.mIssuerID));
|
||||||
|
|
||||||
|
if (sleEnd)
|
||||||
|
{
|
||||||
|
// On a non-XRP account:
|
||||||
bool bRequireAuth = isSetBit(sleEnd->getFieldU32(sfFlags), lsfRequireAuth);
|
bool bRequireAuth = isSetBit(sleEnd->getFieldU32(sfFlags), lsfRequireAuth);
|
||||||
|
|
||||||
BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
|
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));
|
% RippleAddress::createHumanAccountID(uPeerID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Every book that wants the source currency.
|
// Every book that wants the source currency.
|
||||||
std::vector<OrderBook::pointer> books;
|
std::vector<OrderBook::pointer> books;
|
||||||
|
|
||||||
|
|
||||||
theApp->getOrderBookDB().getBooks(speEnd.mIssuerID, speEnd.mCurrencyID, books);
|
theApp->getOrderBookDB().getBooks(speEnd.mIssuerID, speEnd.mCurrencyID, books);
|
||||||
|
|
||||||
BOOST_FOREACH(OrderBook::ref book, 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);
|
STPath spNew(spPath);
|
||||||
STPathElement speBook(ACCOUNT_XRP, book->getCurrencyOut(), book->getIssuerOut());
|
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);
|
qspExplore.push(spNew);
|
||||||
|
|
||||||
bContinued = true;
|
bContinued = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user