mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
add RippleLines
This commit is contained in:
48
src/RippleLines.cpp
Normal file
48
src/RippleLines.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "RippleLines.h"
|
||||
#include "Application.h"
|
||||
#include "Log.h"
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
RippleLines::RippleLines(const uint160& accountID, Ledger::pointer ledger)
|
||||
{
|
||||
fillLines(accountID,ledger);
|
||||
}
|
||||
|
||||
RippleLines::RippleLines(const uint160& accountID )
|
||||
{
|
||||
fillLines(accountID,theApp->getMasterLedger().getCurrentLedger());
|
||||
}
|
||||
|
||||
void RippleLines::fillLines(const uint160& accountID, Ledger::pointer ledger)
|
||||
{
|
||||
uint256 rootIndex = Ledger::getRippleDirIndex(accountID);
|
||||
uint256 currentIndex=rootIndex;
|
||||
|
||||
LedgerStateParms lspNode = lepNONE;
|
||||
|
||||
while(1)
|
||||
{
|
||||
SerializedLedgerEntry::pointer rippleDir=ledger->getDirNode(lspNode,currentIndex);
|
||||
if(!rippleDir) return;
|
||||
|
||||
STVector256 svRippleNodes = rippleDir->getIFieldV256(sfIndexes);
|
||||
BOOST_FOREACH(uint256& uNode, svRippleNodes.peekValue())
|
||||
{
|
||||
RippleState::pointer rsLine = ledger->accessRippleState(uNode);
|
||||
if (rsLine)
|
||||
{
|
||||
rsLine->setViewAccount(accountID);
|
||||
mLines.push_back(rsLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lsWARNING) << "doRippleLinesGet: Bad index: " << uNode.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
uint64 uNodeNext = rippleDir->getIFieldU64(sfIndexNext);
|
||||
if(!uNodeNext) return;
|
||||
|
||||
currentIndex = Ledger::getDirNodeIndex(rootIndex, uNodeNext);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user