mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add 'visitAccountItems' function.
This commit is contained in:
@@ -1020,6 +1020,31 @@ SLE::pointer Ledger::getSLEi(const uint256& uId)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Ledger::visitAccountItems(const uint160& accountID, FUNCTION_TYPE<void(SLE::ref)> func)
|
||||
{ // Visit each item in this account's owner directory
|
||||
uint256 rootIndex = Ledger::getOwnerDirIndex(accountID);
|
||||
uint256 currentIndex = rootIndex;
|
||||
|
||||
while (1)
|
||||
{
|
||||
SLE::pointer ownerDir = getSLEi(currentIndex);
|
||||
if (!ownerDir || (ownerDir->getType() != ltDIR_NODE))
|
||||
return;
|
||||
|
||||
BOOST_FOREACH(const uint256& uNode, ownerDir->getFieldV256(sfIndexes).peekValue())
|
||||
{
|
||||
func(getSLEi(uNode));
|
||||
}
|
||||
|
||||
uint64 uNodeNext = ownerDir->getFieldU64(sfIndexNext);
|
||||
if (!uNodeNext)
|
||||
return;
|
||||
|
||||
currentIndex = Ledger::getDirNodeIndex(rootIndex, uNodeNext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint256 Ledger::getFirstLedgerIndex()
|
||||
{
|
||||
SHAMapItem::pointer node = mAccountStateMap->peekFirstItem();
|
||||
|
||||
@@ -189,6 +189,7 @@ public:
|
||||
SLE::pointer getAccountRoot(const uint160& accountID);
|
||||
SLE::pointer getAccountRoot(const RippleAddress& naAccountID);
|
||||
void updateSkipList();
|
||||
void visitAccountItems(const uint160& acctID, FUNCTION_TYPE<void(SLE::ref)>);
|
||||
|
||||
// database functions (low-level)
|
||||
static Ledger::pointer loadByIndex(uint32 ledgerIndex);
|
||||
|
||||
Reference in New Issue
Block a user