mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Fix a bug where we negate the balance during pathfinding.
This commit is contained in:
@@ -424,7 +424,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
|||||||
}
|
}
|
||||||
else if (!rspEntry->getBalance().isPositive() // No IOUs to send.
|
else if (!rspEntry->getBalance().isPositive() // No IOUs to send.
|
||||||
&& (!rspEntry->getLimitPeer() // Peer does not extend credit.
|
&& (!rspEntry->getLimitPeer() // Peer does not extend credit.
|
||||||
|| *rspEntry->getBalance().negate() >= rspEntry->getLimitPeer() // No credit left.
|
|| -rspEntry->getBalance() >= rspEntry->getLimitPeer() // No credit left.
|
||||||
|| (bRequireAuth && !rspEntry->getAuth()))) // Not authorized to hold credit.
|
|| (bRequireAuth && !rspEntry->getAuth()))) // Not authorized to hold credit.
|
||||||
{
|
{
|
||||||
// Path has no credit left. Ignore it.
|
// Path has no credit left. Ignore it.
|
||||||
@@ -700,7 +700,7 @@ boost::unordered_set<uint160> usAccountSourceCurrencies(const RippleAddress& raA
|
|||||||
// Filter out non
|
// Filter out non
|
||||||
if (saBalance.isPositive() // Have IOUs to send.
|
if (saBalance.isPositive() // Have IOUs to send.
|
||||||
|| (rspEntry->getLimitPeer() // Peer extends credit.
|
|| (rspEntry->getLimitPeer() // Peer extends credit.
|
||||||
&& *saBalance.negate() < rspEntry->getLimitPeer())) // Credit left.
|
&& -saBalance < rspEntry->getLimitPeer())) // Credit left.
|
||||||
{
|
{
|
||||||
// Path has no credit left. Ignore it.
|
// Path has no credit left. Ignore it.
|
||||||
usCurrencies.insert(saBalance.getCurrency());
|
usCurrencies.insert(saBalance.getCurrency());
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ TER PathState::pushNode(
|
|||||||
|
|
||||||
STAmount saOwed = lesEntries.rippleOwed(pnCur.uAccountID, pnBck.uAccountID, pnCur.uCurrencyID);
|
STAmount saOwed = lesEntries.rippleOwed(pnCur.uAccountID, pnBck.uAccountID, pnCur.uCurrencyID);
|
||||||
|
|
||||||
if (!saOwed.isPositive() && *saOwed.negate() >= lesEntries.rippleLimit(pnCur.uAccountID, pnBck.uAccountID, pnCur.uCurrencyID))
|
if (!saOwed.isPositive() && -saOwed >= lesEntries.rippleLimit(pnCur.uAccountID, pnBck.uAccountID, pnCur.uCurrencyID))
|
||||||
{
|
{
|
||||||
terResult = tecPATH_DRY;
|
terResult = tecPATH_DRY;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -364,14 +364,14 @@ public:
|
|||||||
bool isGEZero() const { return !mIsNegative; }
|
bool isGEZero() const { return !mIsNegative; }
|
||||||
operator bool() const { return !isZero(); }
|
operator bool() const { return !isZero(); }
|
||||||
|
|
||||||
STAmount* negate() { if (!isZero()) mIsNegative = !mIsNegative; return this; }
|
void negate() { if (!isZero()) mIsNegative = !mIsNegative; }
|
||||||
STAmount* zero() { mOffset = mIsNative ? 0 : -100; mValue = 0; mIsNegative = false; return this; }
|
void zero() { mOffset = mIsNative ? 0 : -100; mValue = 0; mIsNegative = false; }
|
||||||
|
|
||||||
// Zero while copying currency and issuer.
|
// Zero while copying currency and issuer.
|
||||||
STAmount* zero(const STAmount& saTmpl)
|
void zero(const STAmount& saTmpl)
|
||||||
{ mCurrency = saTmpl.mCurrency; mIssuer = saTmpl.mIssuer; mIsNative = saTmpl.mIsNative; return zero(); }
|
{ mCurrency = saTmpl.mCurrency; mIssuer = saTmpl.mIssuer; mIsNative = saTmpl.mIsNative; zero(); }
|
||||||
STAmount* zero(const uint160& uCurrencyID, const uint160& uIssuerID)
|
void zero(const uint160& uCurrencyID, const uint160& uIssuerID)
|
||||||
{ mCurrency = uCurrencyID; mIssuer = uIssuerID; mIsNative = !uCurrencyID; return zero(); }
|
{ mCurrency = uCurrencyID; mIssuer = uIssuerID; mIsNative = !uCurrencyID; zero(); }
|
||||||
|
|
||||||
int compare(const STAmount&) const;
|
int compare(const STAmount&) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user