mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Default owner count to 0 if not available.
This commit is contained in:
@@ -845,7 +845,7 @@ bool LedgerEntrySet::dirNext(
|
||||
}
|
||||
|
||||
// If there is a count, adjust the owner count by iAmount. Otherwise, compute the owner count and store it.
|
||||
TER LedgerEntrySet::ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::ref sleAccountRoot)
|
||||
void LedgerEntrySet::ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::ref sleAccountRoot)
|
||||
{
|
||||
SLE::pointer sleHold = sleAccountRoot
|
||||
? SLE::pointer()
|
||||
@@ -855,31 +855,10 @@ TER LedgerEntrySet::ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::
|
||||
? sleAccountRoot
|
||||
: sleHold;
|
||||
|
||||
const bool bHaveOwnerCount = sleRoot->isFieldPresent(sfOwnerCount);
|
||||
TER terResult;
|
||||
const uint32 uOwnerCount = sleRoot->getFieldU32(sfOwnerCount);
|
||||
|
||||
if (bHaveOwnerCount)
|
||||
{
|
||||
const uint32 uOwnerCount = sleRoot->getFieldU32(sfOwnerCount);
|
||||
|
||||
if (iAmount + int(uOwnerCount) >= 0)
|
||||
sleRoot->setFieldU32(sfOwnerCount, uOwnerCount+iAmount);
|
||||
|
||||
terResult = tesSUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 uActualCount;
|
||||
|
||||
terResult = dirCount(Ledger::getOwnerDirIndex(uOwnerID), uActualCount);
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
sleRoot->setFieldU32(sfOwnerCount, uActualCount);
|
||||
}
|
||||
}
|
||||
|
||||
return terResult;
|
||||
if (iAmount + int(uOwnerCount) >= 0)
|
||||
sleRoot->setFieldU32(sfOwnerCount, uOwnerCount+iAmount);
|
||||
}
|
||||
|
||||
TER LedgerEntrySet::offerDelete(const SLE::pointer& sleOffer, const uint256& uOfferIndex, const uint160& uOwnerID)
|
||||
@@ -889,11 +868,8 @@ TER LedgerEntrySet::offerDelete(const SLE::pointer& sleOffer, const uint256& uOf
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
terResult = ownerCountAdjust(uOwnerID, -1);
|
||||
}
|
||||
ownerCountAdjust(uOwnerID, -1);
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
uint256 uDirectory = sleOffer->getFieldH256(sfBookDirectory);
|
||||
uint64 uBookNode = sleOffer->getFieldU64(sfBookNode);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
bool dirNext(const uint256& uRootIndex, SLE::pointer& sleNode, unsigned int& uDirEntry, uint256& uEntryIndex);
|
||||
TER dirCount(const uint256& uDirIndex, uint32& uCount);
|
||||
|
||||
TER ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::ref sleAccountRoot=SLE::pointer());
|
||||
void ownerCountAdjust(const uint160& uOwnerID, int iAmount, SLE::ref sleAccountRoot=SLE::pointer());
|
||||
|
||||
// Offer functions.
|
||||
TER offerDelete(const uint256& uOfferIndex);
|
||||
|
||||
@@ -397,14 +397,11 @@ TER OfferCreateTransactor::doApply()
|
||||
boost::bind(&Ledger::qualityDirDescriber, _1, saTakerPays.getCurrency(), uPaysIssuerID,
|
||||
saTakerGets.getCurrency(), uGetsIssuerID, uRate));
|
||||
|
||||
// Update owner count.
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
terResult = mEngine->getNodes().ownerCountAdjust(mTxnAccountID, 1, mTxnAccount);
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
mEngine->getNodes().ownerCountAdjust(mTxnAccountID, 1, mTxnAccount); // Update owner count.
|
||||
|
||||
uint256 uBookBase = Ledger::getBookBase(uPaysCurrency, uPaysIssuerID, uGetsCurrency, uGetsIssuerID);
|
||||
|
||||
Log(lsINFO) << boost::str(boost::format("doOfferCreate: adding to book: %s : %s/%s -> %s/%s")
|
||||
|
||||
@@ -180,50 +180,44 @@ TER TrustSetTransactor::doApply()
|
||||
{
|
||||
// Set reserve for low account.
|
||||
|
||||
terResult = mEngine->getNodes().ownerCountAdjust(uLowAccountID, 1, sleLowAccount);
|
||||
mEngine->getNodes().ownerCountAdjust(uLowAccountID, 1, sleLowAccount);
|
||||
uFlagsOut |= lsfLowReserve;
|
||||
|
||||
if (!bHigh)
|
||||
bReserveIncrease = true;
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult && bLowReserveClear && bLowReserved)
|
||||
if (bLowReserveClear && bLowReserved)
|
||||
{
|
||||
// Clear reserve for low account.
|
||||
|
||||
terResult = mEngine->getNodes().ownerCountAdjust(uLowAccountID, -1, sleLowAccount);
|
||||
mEngine->getNodes().ownerCountAdjust(uLowAccountID, -1, sleLowAccount);
|
||||
uFlagsOut &= ~lsfLowReserve;
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult && bHighReserveSet && !bHighReserved)
|
||||
if (bHighReserveSet && !bHighReserved)
|
||||
{
|
||||
// Set reserve for high account.
|
||||
|
||||
terResult = mEngine->getNodes().ownerCountAdjust(uHighAccountID, 1, sleHighAccount);
|
||||
mEngine->getNodes().ownerCountAdjust(uHighAccountID, 1, sleHighAccount);
|
||||
uFlagsOut |= lsfHighReserve;
|
||||
|
||||
if (bHigh)
|
||||
bReserveIncrease = true;
|
||||
}
|
||||
|
||||
if (tesSUCCESS == terResult && bHighReserveClear && bHighReserved)
|
||||
if (bHighReserveClear && bHighReserved)
|
||||
{
|
||||
// Clear reserve for high account.
|
||||
|
||||
terResult = mEngine->getNodes().ownerCountAdjust(uHighAccountID, -1, sleHighAccount);
|
||||
mEngine->getNodes().ownerCountAdjust(uHighAccountID, -1, sleHighAccount);
|
||||
uFlagsOut &= ~lsfHighReserve;
|
||||
}
|
||||
|
||||
if (uFlagsIn != uFlagsOut)
|
||||
sleRippleState->setFieldU32(sfFlags, uFlagsOut);
|
||||
|
||||
if (tesSUCCESS != terResult)
|
||||
{
|
||||
Log(lsINFO) << "doTrustSet: Error";
|
||||
|
||||
nothing();
|
||||
}
|
||||
else if (bDefault)
|
||||
if (bDefault)
|
||||
{
|
||||
// Can delete.
|
||||
|
||||
@@ -299,14 +293,15 @@ TER TrustSetTransactor::doApply()
|
||||
boost::bind(&Ledger::ownerDirDescriber, _1, mTxnAccountID));
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
terResult = mEngine->getNodes().ownerCountAdjust(mTxnAccountID, 1, mTxnAccount);
|
||||
{
|
||||
mEngine->getNodes().ownerCountAdjust(mTxnAccountID, 1, mTxnAccount);
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
terResult = mEngine->getNodes().dirAdd(
|
||||
uSrcRef,
|
||||
Ledger::getOwnerDirIndex(uDstAccountID),
|
||||
sleRippleState->getIndex(),
|
||||
boost::bind(&Ledger::ownerDirDescriber, _1, uDstAccountID));
|
||||
}
|
||||
}
|
||||
|
||||
Log(lsINFO) << "doTrustSet<";
|
||||
|
||||
Reference in New Issue
Block a user