DirectoryEntryIterator fix

This commit is contained in:
JoelKatz
2014-01-23 21:48:08 -08:00
parent 1b37b52071
commit b5ffa2351a
2 changed files with 8 additions and 8 deletions

View File

@@ -30,7 +30,7 @@ bool DirectoryEntryIterator::firstEntry (LedgerEntrySet& les)
{
WriteLog (lsTRACE, Ledger) << "DirectoryEntryIterator::firstEntry(" << mRootIndex.GetHex() << ")";
mEntry = 0;
mDirIndex = mRootIndex;
mDirNode.reset ();
return nextEntry (les);
}
@@ -40,7 +40,7 @@ bool DirectoryEntryIterator::firstEntry (LedgerEntrySet& les)
bool DirectoryEntryIterator::nextEntry (LedgerEntrySet& les)
{
if (!mDirNode || mDirNode->getIndex() != mDirIndex)
if (!mDirNode)
{
WriteLog (lsTRACE, Ledger) << "DirectoryEntryIterator::nextEntry(" << mRootIndex.GetHex() << ") need dir node";
// Are we already at the end
@@ -77,8 +77,11 @@ bool DirectoryEntryIterator::addJson (Json::Value& j) const
if (mDirNode && (mEntry != 0))
{
j["dir_root"] = mRootIndex.GetHex();
j["dir_index"] = mDirIndex.GetHex();
j["dir_entry"] = static_cast<Json::UInt> (mEntry);
if (mDirNode)
j["dir_index"] = mDirIndex.GetHex();
return true;
}
return false;

View File

@@ -38,10 +38,7 @@ public:
DirectoryEntryIterator (SLE::ref directory) : mEntry (0), mDirNode (directory)
{
if (mDirNode)
{
mDirIndex = mDirNode->getIndex();
mRootIndex = mDirNode->getIndex();
}
}
/** Get the SLE this iterator currently references
@@ -69,9 +66,9 @@ public:
return mEntryIndex;
}
uint256 const& getDirectory () const
uint256 getDirectory () const
{
return mDirIndex;
return mDirNode ? mDirNode->getIndex () : uint256();
}
private: