mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Don't count forced issuer nodes after exchanges because we didn't have to find them.
Drop the default maximum path length to four because exchanges to non-XRP aren't overcounted.
This commit is contained in:
@@ -251,7 +251,7 @@
|
||||
# When searching for paths, the maximum number of nodes allowed. This can take
|
||||
# exponentially more resources as the size is increased.
|
||||
#
|
||||
# The default is: 5
|
||||
# The default is: 4
|
||||
#
|
||||
# [rpc_startup]
|
||||
# Specify a list of RPC commands to run at startup.
|
||||
|
||||
@@ -118,7 +118,7 @@ bool Pathfinder::bDefaultPath(const STPath& spPath)
|
||||
}
|
||||
|
||||
typedef std::pair<int, uint160> candidate_t;
|
||||
bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second)
|
||||
static bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second)
|
||||
{
|
||||
if (first.first < second.first)
|
||||
return false;
|
||||
@@ -127,6 +127,17 @@ bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second)
|
||||
return (first.first ^ seq) < (second.first ^ seq);
|
||||
}
|
||||
|
||||
static int getEffectiveLength(const STPath& spPath)
|
||||
{ // don't count exchanges to non-XRP currencies twice (only count the forced issuer account node)
|
||||
int length = 0;
|
||||
for (std::vector<STPathElement>::const_iterator it = spPath.begin(); it != spPath.end(); ++it)
|
||||
{
|
||||
if (it->isAccount() || it->getCurrency().isZero())
|
||||
++length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
Pathfinder::Pathfinder(Ledger::ref ledger,
|
||||
const RippleAddress& uSrcAccountID, const RippleAddress& uDstAccountID,
|
||||
const uint160& uSrcCurrencyID, const uint160& uSrcIssuerID, const STAmount& saDstAmount, bool& bValid)
|
||||
@@ -360,7 +371,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
% STAmount::createHumanCurrency(speEnd.mCurrencyID)
|
||||
% RippleAddress::createHumanAccountID(speEnd.mIssuerID));
|
||||
|
||||
if (spPath.mPath.size() >= iMaxSteps)
|
||||
int length = getEffectiveLength(spPath.mPath);
|
||||
if (length >= iMaxSteps)
|
||||
{
|
||||
// Path is at maximum size. Don't want to add more.
|
||||
|
||||
@@ -369,12 +381,10 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
|
||||
continue;
|
||||
}
|
||||
bool isLast = (spPath.mPath.size() == (iMaxSteps - 1));
|
||||
bool isLast = (length == (iMaxSteps - 1));
|
||||
|
||||
if (!speEnd.mCurrencyID)
|
||||
{
|
||||
// XXX Might restrict the number of times bridging through XRP.
|
||||
|
||||
// Cursor is for XRP, continue with qualifying books: XRP -> non-XRP
|
||||
std::vector<OrderBook::pointer> xrpBooks;
|
||||
theApp->getOrderBookDB().getBooksByTakerPays(ACCOUNT_XRP, CURRENCY_XRP, xrpBooks);
|
||||
|
||||
Reference in New Issue
Block a user