mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 19:25:51 +00:00
Add LES::dirIsEmpty function to check if a directory is empty
This commit is contained in:
committed by
Vinnie Falco
parent
d474d68566
commit
00c87ca2dd
@@ -633,6 +633,22 @@ TER LedgerEntrySet::dirCount (uint256 const& uRootIndex, uint32& uCount)
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
bool LedgerEntrySet::dirIsEmpty (uint256 const& uRootIndex)
|
||||
{
|
||||
uint64 uNodeDir = 0;
|
||||
|
||||
SLE::pointer sleNode = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeDir));
|
||||
|
||||
if (!sleNode)
|
||||
return true;
|
||||
|
||||
if (!sleNode->getFieldV256 (sfIndexes).peekValue ().empty ())
|
||||
return false;
|
||||
|
||||
// If there's another page, it must be non-empty
|
||||
return sleNode->getFieldU64 (sfIndexNext) == 0;
|
||||
}
|
||||
|
||||
// <-- uNodeDir: For deletion, present to make dirDelete efficient.
|
||||
// --> uRootIndex: The index of the base of the directory. Nodes are based off of this.
|
||||
// --> uLedgerIndex: Value to add to directory.
|
||||
|
||||
@@ -172,6 +172,7 @@ public:
|
||||
|
||||
bool dirFirst (uint256 const & uRootIndex, SLE::pointer & sleNode, unsigned int & uDirEntry, uint256 & uEntryIndex);
|
||||
bool dirNext (uint256 const & uRootIndex, SLE::pointer & sleNode, unsigned int & uDirEntry, uint256 & uEntryIndex);
|
||||
bool dirIsEmpty (uint256 const & uDirIndex);
|
||||
TER dirCount (uint256 const & uDirIndex, uint32 & uCount);
|
||||
|
||||
uint256 getNextLedgerIndex (uint256 const & uHash);
|
||||
|
||||
@@ -59,9 +59,9 @@ TER AccountSetTransactor::doApply ()
|
||||
|
||||
if (bSetRequireAuth && !isSetBit (uFlagsIn, lsfRequireAuth))
|
||||
{
|
||||
if (mTxnAccount->getFieldU32 (sfOwnerCount))
|
||||
if (!mEngine->getNodes ().dirIsEmpty (Ledger::getOwnerDirIndex (mTxnAccountID)))
|
||||
{
|
||||
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Retry: OwnerCount not zero.";
|
||||
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Retry: Owner directory not empty.";
|
||||
|
||||
return isSetBit(mParams, tapRETRY) ? terOWNERS : tecOWNERS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user