Freeze flags: (RIPD-394)

* Define all flags
 * Set/clear bits in transactors
 * Frozen line counts towards reserve, is non-default
 * Report trust line state
This commit is contained in:
JoelKatz
2014-05-22 14:22:15 -07:00
committed by David Schwartz
parent 07db5d497c
commit 4cf29455e4
9 changed files with 79 additions and 1 deletions

View File

@@ -1367,6 +1367,7 @@ TER LedgerEntrySet::trustCreate (
SLE::ref sleAccount, // --> the account being set.
const bool bAuth, // --> authorize account.
const bool bNoRipple, // --> others cannot ripple through
const bool bFreeze, // --> funds cannot leave
const STAmount& saBalance, // --> balance of account being set.
// Issuer should be noAccount()
const STAmount& saLimit, // --> limit for account being set.
@@ -1435,6 +1436,10 @@ TER LedgerEntrySet::trustCreate (
{
uFlags |= (bSetHigh ? lsfHighNoRipple : lsfLowNoRipple);
}
if (bFreeze)
{
uFlags |= (!bSetHigh ? lsfLowFreeze : lsfHighFreeze);
}
sleRippleState->setFieldU32 (sfFlags, uFlags);
ownerCountAdjust (
@@ -1536,6 +1541,7 @@ TER LedgerEntrySet::rippleCredit (
entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uReceiverID)),
false,
false,
false,
saBalance,
saReceiverLimit);
}
@@ -1568,6 +1574,7 @@ TER LedgerEntrySet::rippleCredit (
&& (uFlags & (!bSenderHigh ? lsfLowReserve : lsfHighReserve))
// Sender reserve is set.
&& !(uFlags & (!bSenderHigh ? lsfLowNoRipple : lsfHighNoRipple))
&& !(uFlags & (!bSenderHigh ? lsfLowFreeze : lsfHighFreeze))
&& !sleRippleState->getFieldAmount (
!bSenderHigh ? sfLowLimit : sfHighLimit)
// Sender trust limit is 0.

View File

@@ -246,6 +246,7 @@ public:
SLE::ref sleAccount,
const bool bAuth,
const bool bNoRipple,
const bool bFreeze,
const STAmount& saSrcBalance,
const STAmount& saSrcLimit,
const std::uint32_t uSrcQualityIn = 0,

View File

@@ -78,6 +78,18 @@ public:
return mFlags & (!mViewLowest ? lsfLowNoRipple : lsfHighNoRipple);
}
/** Have we set the freeze flag on our peer */
bool getFreeze () const
{
return mFlags & (mViewLowest ? lsfLowFreeze : lsfHighFreeze);
}
/** Has the peer set the freeze flag on us */
bool getFreezePeer () const
{
return mFlags & (!mViewLowest ? lsfLowFreeze : lsfHighFreeze);
}
const STAmount& getBalance () const
{
return mBalance;

View File

@@ -29,6 +29,12 @@ TER SetAccount::doApply ()
std::uint32_t const uSetFlag = mTxn.getFieldU32 (sfSetFlag);
std::uint32_t const uClearFlag = mTxn.getFieldU32 (sfClearFlag);
if ((uSetFlag != 0) && (uSetFlag == uClearFlag))
{
m_journal.trace << "Malformed transaction: Set and clear same flag";
return temINVALID_FLAG;
}
// legacy AccountSet flags
bool bSetRequireDest = (uTxFlags & TxFlag::requireDestTag) || (uSetFlag == asfRequireDest);
bool bClearRequireDest = (uTxFlags & tfOptionalDestTag) || (uClearFlag == asfRequireDest);
@@ -141,6 +147,29 @@ TER SetAccount::doApply ()
uFlagsOut &= ~lsfDisableMaster;
}
if ((uSetFlag == asfNoFreeze) && (uClearFlag != asfNoFreeze))
{
m_journal.trace << "Set NoFreeze flag";
uFlagsOut |= lsfNoFreeze;
}
// Anyone may set global freeze
if ((uSetFlag == asfGlobalFreeze) && (uClearFlag != asfGlobalFreeze))
{
m_journal.trace << "Set GlobalFreeze flag";
uFlagsOut |= lsfGlobalFreeze;
}
// If you have set NoFreeze, you may not clear GlobalFreeze
// This prevents those who have set NoFreeze from using
// GlobalFreeze strategically.
if ((uSetFlag != asfGlobalFreeze) && (uClearFlag == asfGlobalFreeze) &&
((uFlagsOut & lsfNoFreeze) == 0))
{
m_journal.trace << "Clear GlobalFreeze flag";
uFlagsOut &= ~lsfGlobalFreeze;
}
//
// Track transaction IDs signed by this account in its root
//

View File

@@ -57,6 +57,8 @@ TER SetTrust::doApply ()
bool const bSetAuth = (uTxFlags & tfSetfAuth);
bool const bSetNoRipple = (uTxFlags & tfSetNoRipple);
bool const bClearNoRipple = (uTxFlags & tfClearNoRipple);
bool const bSetFreeze = (uTxFlags & tfSetFreeze);
bool const bClearFreeze = (uTxFlags & tfClearFreeze);
if (bSetAuth && !(mTxnAccount->getFieldU32 (sfFlags) & lsfRequireAuth))
{
@@ -242,6 +244,15 @@ TER SetTrust::doApply ()
uFlagsOut &= ~(bHigh ? lsfHighNoRipple : lsfLowNoRipple);
}
if (bSetFreeze && !bClearFreeze && !mTxnAccount->isFlag (lsfNoFreeze))
{
uFlagsOut |= (bHigh ? lsfHighFreeze : lsfLowFreeze);
}
else if (bClearFreeze && !bSetFreeze)
{
uFlagsOut &= ~(bHigh ? lsfHighFreeze : lsfLowFreeze);
}
if (QUALITY_ONE == uLowQualityOut) uLowQualityOut = 0;
if (QUALITY_ONE == uHighQualityOut) uHighQualityOut = 0;
@@ -249,11 +260,13 @@ TER SetTrust::doApply ()
bool const bLowReserveSet = uLowQualityIn || uLowQualityOut ||
(uFlagsOut & lsfLowNoRipple) ||
(uFlagsOut & lsfLowFreeze) ||
!!saLowLimit || saLowBalance > zero;
bool const bLowReserveClear = !bLowReserveSet;
bool const bHighReserveSet = uHighQualityIn || uHighQualityOut ||
(uFlagsOut & lsfHighNoRipple) ||
(uFlagsOut & lsfHighFreeze) ||
!!saHighLimit || saHighBalance > zero;
bool const bHighReserveClear = !bHighReserveSet;
@@ -375,6 +388,7 @@ TER SetTrust::doApply ()
mTxnAccount,
bSetAuth,
bSetNoRipple && !bClearNoRipple,
bSetFreeze && !bClearFreeze,
saBalance,
saLimitAllow, // Limit for who is being charged.
uQualityIn,