From b5ffa2351a69da6d8a747b5e5aa0e9bccba72cdb Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 23 Jan 2014 21:48:08 -0800 Subject: [PATCH] DirectoryEntryIterator fix --- src/ripple_app/ledger/DirectoryEntryIterator.cpp | 9 ++++++--- src/ripple_app/ledger/DirectoryEntryIterator.h | 7 ++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ripple_app/ledger/DirectoryEntryIterator.cpp b/src/ripple_app/ledger/DirectoryEntryIterator.cpp index 04a4c304a..c0a071f78 100644 --- a/src/ripple_app/ledger/DirectoryEntryIterator.cpp +++ b/src/ripple_app/ledger/DirectoryEntryIterator.cpp @@ -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 (mEntry); + + if (mDirNode) + j["dir_index"] = mDirIndex.GetHex(); + return true; } return false; diff --git a/src/ripple_app/ledger/DirectoryEntryIterator.h b/src/ripple_app/ledger/DirectoryEntryIterator.h index 48450584a..aca609ef9 100644 --- a/src/ripple_app/ledger/DirectoryEntryIterator.h +++ b/src/ripple_app/ledger/DirectoryEntryIterator.h @@ -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: