mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
Have PathFinding respect authorized accounts.
This commit is contained in:
@@ -244,8 +244,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Remove implied first and last nodes.
|
||||
|
||||
spPath.mPath.erase(spPath.mPath.begin());
|
||||
spPath.mPath.erase(spPath.mPath.begin() + spPath.mPath.size()-1);
|
||||
|
||||
@@ -302,6 +302,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
|
||||
// Create new paths for each outbound account not already in the path.
|
||||
AccountItems rippleLines(speEnd.mAccountID, mLedger, AccountItem::pointer(new RippleState()));
|
||||
SLE::pointer sleSrc = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(speEnd.mAccountID));
|
||||
bool bRequireAuth = isSetBit(sleSrc->getFieldU32(sfFlags), lsfRequireAuth);
|
||||
|
||||
BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
|
||||
{
|
||||
@@ -319,7 +321,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
}
|
||||
else if (!rspEntry->getBalance().isPositive() // No IOUs to send.
|
||||
&& (!rspEntry->getLimitPeer() // Peer does not extend credit.
|
||||
|| *rspEntry->getBalance().negate() >= rspEntry->getLimitPeer())) // No credit left.
|
||||
|| *rspEntry->getBalance().negate() >= rspEntry->getLimitPeer() // No credit left.
|
||||
|| (bRequireAuth && !rspEntry->getAuth()))) // Not authorized to hold credit.
|
||||
{
|
||||
// Path has no credit left. Ignore it.
|
||||
cLog(lsDEBUG) <<
|
||||
|
||||
@@ -14,6 +14,8 @@ RippleState::RippleState(SerializedLedgerEntry::ref ledgerEntry) : AccountItem(l
|
||||
mValid(false),
|
||||
mViewLowest(true)
|
||||
{
|
||||
mFlags = mLedgerEntry->getFieldU32(sfFlags);
|
||||
|
||||
mLowLimit = mLedgerEntry->getFieldAmount(sfLowLimit);
|
||||
mHighLimit = mLedgerEntry->getFieldAmount(sfHighLimit);
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
typedef boost::shared_ptr<RippleState> pointer;
|
||||
|
||||
private:
|
||||
uint32 mFlags;
|
||||
|
||||
RippleAddress mLowID;
|
||||
RippleAddress mHighID;
|
||||
|
||||
@@ -43,12 +45,15 @@ public:
|
||||
void setViewAccount(const uint160& accountID);
|
||||
|
||||
const RippleAddress getAccountID() const { return mViewLowest ? mLowID : mHighID; }
|
||||
const RippleAddress getAccountIDPeer() const { return mViewLowest ? mHighID : mLowID; }
|
||||
const RippleAddress getAccountIDPeer() const { return !mViewLowest ? mLowID : mHighID; }
|
||||
|
||||
bool getAuth() const { return isSetBit(mFlags, mViewLowest ? lsfLowAuth : lsfHighAuth); }
|
||||
bool getAuthPeer() const { return isSetBit(mFlags, !mViewLowest ? lsfLowAuth : lsfHighAuth); }
|
||||
|
||||
STAmount getBalance() const { return mBalance; }
|
||||
|
||||
STAmount getLimit() const { return mViewLowest ? mLowLimit : mHighLimit; }
|
||||
STAmount getLimitPeer() const { return mViewLowest ? mHighLimit : mLowLimit; }
|
||||
STAmount getLimitPeer() const { return !mViewLowest ? mLowLimit : mHighLimit; }
|
||||
|
||||
uint32 getQualityIn() const { return((uint32) (mViewLowest ? mLowQualityIn : mHighQualityIn)); }
|
||||
uint32 getQualityOut() const { return((uint32) (mViewLowest ? mLowQualityOut : mHighQualityOut)); }
|
||||
|
||||
Reference in New Issue
Block a user