diff --git a/modules/ripple_app/ledger/Ledger.cpp b/modules/ripple_app/ledger/Ledger.cpp index 21281b6547..f912b036d4 100644 --- a/modules/ripple_app/ledger/Ledger.cpp +++ b/modules/ripple_app/ledger/Ledger.cpp @@ -15,7 +15,7 @@ Ledger::Ledger (const RippleAddress& masterID, uint64 startAmount) , mCloseFlags (0) , mClosed (false) , mValidHash (false) - , mAccepted (false) + , mValidated (false) , mImmutable (false) , mTransactionMap (boost::make_shared (smtTRANSACTION)) , mAccountStateMap (boost::make_shared (smtSTATE)) @@ -59,7 +59,7 @@ Ledger::Ledger (uint256 const& parentHash, , mCloseFlags (closeFlags) , mClosed (false) , mValidHash (false) - , mAccepted (false) + , mValidated (false) , mImmutable (true) , mTransactionMap (boost::make_shared (smtTRANSACTION, transHash)) , mAccountStateMap (boost::make_shared (smtSTATE, accountHash)) @@ -98,7 +98,7 @@ Ledger::Ledger (Ledger& ledger, , mCloseFlags (ledger.mCloseFlags) , mClosed (ledger.mClosed) , mValidHash (false) - , mAccepted (ledger.mAccepted) + , mValidated (ledger.mValidated) , mImmutable (!isMutable) , mTransactionMap (ledger.mTransactionMap->snapShot (isMutable)) , mAccountStateMap (ledger.mAccountStateMap->snapShot (isMutable)) @@ -117,7 +117,7 @@ Ledger::Ledger (bool /* dummy */, , mCloseFlags (0) , mClosed (false) , mValidHash (false) - , mAccepted (false) + , mValidated (true) , mImmutable (false) , mTransactionMap (boost::make_shared (smtTRANSACTION)) , mAccountStateMap (prevLedger.mAccountStateMap->snapShot (true)) @@ -149,7 +149,7 @@ Ledger::Ledger (Blob const& rawLedger, bool hasPrefix) : mClosed (false) , mValidHash (false) - , mAccepted (false) + , mValidated (false) , mImmutable (true) { Serializer s (rawLedger); @@ -160,7 +160,7 @@ Ledger::Ledger (Blob const& rawLedger, } Ledger::Ledger (const std::string& rawLedger, bool hasPrefix) : - mClosed (false), mValidHash (false), mAccepted (false), mImmutable (true) + mClosed (false), mValidHash (false), mValidated (false), mImmutable (true) { Serializer s (rawLedger); setRaw (s, hasPrefix); diff --git a/modules/ripple_app/ledger/Ledger.h b/modules/ripple_app/ledger/Ledger.h index 6d0ddc686a..60dde3b94c 100644 --- a/modules/ripple_app/ledger/Ledger.h +++ b/modules/ripple_app/ledger/Ledger.h @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +l//------------------------------------------------------------------------------ /* Copyright (c) 2011-2013, OpenCoin, Inc. */ @@ -93,14 +93,18 @@ public: } void setAccepted (uint32 closeTime, int closeResolution, bool correctCloseTime); void setAccepted (); + void setValidated () + { + mValidated = mClosed = true; + } void setImmutable (); bool isClosed () { return mClosed; } - bool isAccepted () + bool isValidated () { - return mAccepted; + return mValidated; } bool isImmutable () { @@ -426,7 +430,7 @@ protected: // returned SLE is immutable SLE::pointer getASNodeI (uint256 const & nodeID, LedgerEntryType let); - void saveAcceptedLedger (Job&, bool fromConsensus); + void saveValidatedLedger (Job&); void updateFees (); @@ -449,7 +453,7 @@ private: uint32 mParentCloseTime; // when the previous ledger closed int mCloseResolution; // the resolution for this ledger close time (2-120 seconds) uint32 mCloseFlags; // flags indicating how this ledger close took place - bool mClosed, mValidHash, mAccepted, mImmutable; + bool mClosed, mValidHash, mValidated, mImmutable; uint32 mReferenceFeeUnits; // Fee units for the reference transaction uint32 mReserveBase, mReserveIncrement; // Reserve basse and increment in fee units diff --git a/modules/ripple_app/ledger/ripple_LedgerEntrySet.cpp b/modules/ripple_app/ledger/ripple_LedgerEntrySet.cpp index 29fb941fa8..e8ff11f83b 100644 --- a/modules/ripple_app/ledger/ripple_LedgerEntrySet.cpp +++ b/modules/ripple_app/ledger/ripple_LedgerEntrySet.cpp @@ -970,6 +970,12 @@ bool LedgerEntrySet::dirNext ( sleNode = entryCache (ltDIR_NODE, Ledger::getDirNodeIndex (uRootIndex, uNodeNext)); uDirEntry = 0; + if (!sleNode) + { // This should never happen + WriteLog (lsFATAL, LedgerEntrySet) << "Corrupt directory: index:" << uRootIndex << " next:" << uNodeNext; + throw std::runtime_error ("Corrupt directory"); + } + return dirNext (uRootIndex, sleNode, uDirEntry, uEntryIndex); } }