mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix some paths we missed.
This commit is contained in:
@@ -121,9 +121,9 @@ typedef std::pair<int, uint160> candidate_t;
|
|||||||
bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second)
|
bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second)
|
||||||
{
|
{
|
||||||
if (first.first < second.first)
|
if (first.first < second.first)
|
||||||
return true;
|
|
||||||
if (first.first > second.first)
|
|
||||||
return false;
|
return false;
|
||||||
|
if (first.first > second.first)
|
||||||
|
return true;
|
||||||
return (first.first ^ seq) < (second.first ^ seq);
|
return (first.first ^ seq) < (second.first ^ seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,13 +464,13 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
|||||||
}
|
}
|
||||||
else if (dstCurrency && (uPeerID == mDstAccountID))
|
else if (dstCurrency && (uPeerID == mDstAccountID))
|
||||||
{ // never skip the destination node
|
{ // never skip the destination node
|
||||||
candidates.push_back(std::make_pair(-1, uPeerID));
|
candidates.push_back(std::make_pair(1000000, uPeerID));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // save this candidate
|
{ // save this candidate
|
||||||
int paths_out = getPathsOut(speEnd.mCurrencyID, uPeerID, dstCurrency, mDstAccountID);
|
int out = getPathsOut(speEnd.mCurrencyID, uPeerID, bRequireAuth, dstCurrency, mDstAccountID);
|
||||||
if (paths_out != 0)
|
if (out != 0)
|
||||||
candidates.push_back(std::make_pair(paths_out, uPeerID));
|
candidates.push_back(std::make_pair(out, uPeerID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,7 +832,7 @@ bool Pathfinder::matchesOrigin(const uint160& currency, const uint160& issuer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Pathfinder::getPathsOut(const uint160& currencyID, const uint160& accountID,
|
int Pathfinder::getPathsOut(const uint160& currencyID, const uint160& accountID,
|
||||||
bool isDstCurrency, const uint160& dstAccount)
|
bool authRequired, bool isDstCurrency, const uint160& dstAccount)
|
||||||
{
|
{
|
||||||
std::pair<const uint160&, const uint160&> accountCurrency(currencyID, accountID);
|
std::pair<const uint160&, const uint160&> accountCurrency(currencyID, accountID);
|
||||||
boost::unordered_map<std::pair<uint160, uint160>, int>::iterator it = mPOMap.find(accountCurrency);
|
boost::unordered_map<std::pair<uint160, uint160>, int>::iterator it = mPOMap.find(accountCurrency);
|
||||||
@@ -846,10 +846,13 @@ int Pathfinder::getPathsOut(const uint160& currencyID, const uint160& accountID,
|
|||||||
RippleState* rspEntry = (RippleState*) item.get();
|
RippleState* rspEntry = (RippleState*) item.get();
|
||||||
if (currencyID != rspEntry->getLimit().getCurrency())
|
if (currencyID != rspEntry->getLimit().getCurrency())
|
||||||
nothing();
|
nothing();
|
||||||
else if (!rspEntry->getBalance().isPositive() && !rspEntry->getLimitPeer().isPositive()) // no credit
|
else if (!rspEntry->getBalance().isPositive() &&
|
||||||
|
(!rspEntry->getLimitPeer()
|
||||||
|
|| -rspEntry->getBalance() >= rspEntry->getLimitPeer()
|
||||||
|
|| (authRequired && !rspEntry->getAuth())))
|
||||||
nothing();
|
nothing();
|
||||||
else if (isDstCurrency && (dstAccount == rspEntry->getAccountIDPeer()))
|
else if (isDstCurrency && (dstAccount == rspEntry->getAccountIDPeer()))
|
||||||
count += 10; // count a path to the destination extra
|
count += 100; // count a path to the destination extra
|
||||||
else
|
else
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ class Pathfinder
|
|||||||
|
|
||||||
AccountItems& getRippleLines(const uint160& accountID);
|
AccountItems& getRippleLines(const uint160& accountID);
|
||||||
|
|
||||||
int getPathsOut(const uint160& currency, const uint160& accountID, bool isDestCurrency, const uint160& dest);
|
int getPathsOut(const uint160& currency, const uint160& accountID,
|
||||||
|
bool isAuthRequired, bool isDestCurrency, const uint160& dest);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Pathfinder(Ledger::ref ledger,
|
Pathfinder(Ledger::ref ledger,
|
||||||
|
|||||||
Reference in New Issue
Block a user