mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
#include "AccountItems.h"
|
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
#include "Application.h"
|
|
#include "Log.h"
|
|
|
|
SETUP_LOG();
|
|
|
|
AccountItem::AccountItem(SerializedLedgerEntry::ref ledger) : mLedgerEntry(ledger)
|
|
{
|
|
|
|
}
|
|
|
|
AccountItems::AccountItems(const uint160& accountID, Ledger::ref ledger, AccountItem::pointer ofType)
|
|
{
|
|
mOfType = ofType;
|
|
|
|
fillItems(accountID, ledger);
|
|
}
|
|
|
|
void AccountItems::fillItems(const uint160& accountID, Ledger::ref ledger)
|
|
{
|
|
uint256 rootIndex = Ledger::getOwnerDirIndex(accountID);
|
|
uint256 currentIndex = rootIndex;
|
|
|
|
while (1)
|
|
{
|
|
SLE::pointer ownerDir = ledger->getDirNode(currentIndex);
|
|
if (!ownerDir) return;
|
|
|
|
STVector256 svOwnerNodes = ownerDir->getFieldV256(sfIndexes);
|
|
|
|
BOOST_FOREACH(uint256& uNode, svOwnerNodes.peekValue())
|
|
{
|
|
SLE::pointer sleCur = ledger->getSLEi(uNode);
|
|
|
|
AccountItem::pointer item = mOfType->makeItem(accountID, sleCur);
|
|
if(item)
|
|
{
|
|
mItems.push_back(item);
|
|
}
|
|
}
|
|
|
|
uint64 uNodeNext = ownerDir->getFieldU64(sfIndexNext);
|
|
if (!uNodeNext) return;
|
|
|
|
currentIndex = Ledger::getDirNodeIndex(rootIndex, uNodeNext);
|
|
}
|
|
}
|
|
|
|
Json::Value AccountItems::getJson(int v)
|
|
{
|
|
Json::Value ret(Json::arrayValue);
|
|
BOOST_FOREACH(AccountItem::ref ai, mItems)
|
|
ret.append(ai->getJson(v));
|
|
return ret;
|
|
}
|
|
|
|
// vim:ts=4
|