diff --git a/src/ripple/app/ledger/InboundLedger.cpp b/src/ripple/app/ledger/InboundLedger.cpp index b8458ffdd..05e05cddb 100644 --- a/src/ripple/app/ledger/InboundLedger.cpp +++ b/src/ripple/app/ledger/InboundLedger.cpp @@ -67,6 +67,20 @@ InboundLedger::InboundLedger (uint256 const& hash, std::uint32_t seq, fcReason r "Acquiring ledger " << mHash; } +void InboundLedger::update (std::uint32_t seq) +{ + ScopedLockType sl (mLock); + + if ((seq != 0) && (mSeq == 0)) + { + // If we didn't know the sequence number, but now do, save it + mSeq = seq; + } + + // Prevent this from being swept + touch (); +} + bool InboundLedger::checkLocal () { ScopedLockType sl (mLock); diff --git a/src/ripple/app/ledger/InboundLedger.h b/src/ripple/app/ledger/InboundLedger.h index 677473a51..49c7f0235 100644 --- a/src/ripple/app/ledger/InboundLedger.h +++ b/src/ripple/app/ledger/InboundLedger.h @@ -55,6 +55,9 @@ public: ~InboundLedger (); + // Called when another attempt is made to fetch this same ledger + void update (std::uint32_t seq); + bool isHeader () const { return mHaveHeader; diff --git a/src/ripple/app/ledger/InboundLedgers.cpp b/src/ripple/app/ledger/InboundLedgers.cpp index f88a259a3..a25ef1671 100644 --- a/src/ripple/app/ledger/InboundLedgers.cpp +++ b/src/ripple/app/ledger/InboundLedgers.cpp @@ -54,47 +54,16 @@ public: assert (hash.isNonZero ()); InboundLedger::pointer ret; - // Ensure that any previous IL is destroyed outside the lock - InboundLedger::pointer oldLedger; - { ScopedLockType sl (mLock); if (! isStopping ()) { - - if (reason == InboundLedger::fcCONSENSUS) - { - if (mConsensusLedger.isNonZero() && (mValidationLedger != mConsensusLedger) && (hash != mConsensusLedger)) - { - hash_map::iterator it = mLedgers.find (mConsensusLedger); - if (it != mLedgers.end ()) - { - oldLedger = it->second; - mLedgers.erase (it); - } - } - mConsensusLedger = hash; - } - else if (reason == InboundLedger::fcVALIDATION) - { - if (mValidationLedger.isNonZero() && (mValidationLedger != mConsensusLedger) && (hash != mValidationLedger)) - { - hash_map::iterator it = mLedgers.find (mValidationLedger); - if (it != mLedgers.end ()) - { - oldLedger = it->second; - mLedgers.erase (it); - } - } - mValidationLedger = hash; - } - - hash_map::iterator it = mLedgers.find (hash); + auto it = mLedgers.find (hash); if (it != mLedgers.end ()) { ret = it->second; - // FIXME: Should set the sequence if it's not set + ret->update (seq); } else { @@ -393,9 +362,6 @@ private: MapType mLedgers; KeyCache mRecentFailures; - uint256 mConsensusLedger; - uint256 mValidationLedger; - beast::insight::Counter mCounter; };