Add 'visitAccountItems' function.

This commit is contained in:
JoelKatz
2013-05-30 13:07:53 -07:00
parent 38abc08e18
commit fdea361dd7
2 changed files with 26 additions and 0 deletions

View File

@@ -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();

View File

@@ -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);