mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +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.
|
||||
|
||||
Reference in New Issue
Block a user