diff --git a/include/xrpl/ledger/LedgerIndexMap.h b/include/xrpl/ledger/LedgerIndexMap.h index aa473d70c3..794af336e5 100644 --- a/include/xrpl/ledger/LedgerIndexMap.h +++ b/include/xrpl/ledger/LedgerIndexMap.h @@ -139,7 +139,7 @@ public: private: std::unordered_map data_; - std::queue order_; // assumes non-decreasing inserts for O(k) purge + std::queue order_; mutable std::mutex mutex_; }; diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index 3a4bc9f870..fc752062fd 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -533,18 +533,24 @@ LedgerHistory::fixIndex(LedgerIndex ledgerIndex, LedgerHash const& ledgerHash) void LedgerHistory::clearLedgerCachePrior(LedgerIndex seq) { + std::size_t hashesCleared = 0; for (LedgerHash it : m_ledgers_by_hash.getKeys()) { auto const ledger = getLedgerByHash(it); if (!ledger || ledger->info().seq < seq) + { m_ledgers_by_hash.del(it, false); + ++hashesCleared; + } } + JLOG(j_.debug()) << "LedgersByHash: cleared " << hashesCleared + << " entries before seq " << seq << " (total now " + << m_ledgers_by_hash.size() << ")"; - JLOG(j_.debug()) << "mLedgersByIndex size before clear: " - << mLedgersByIndex.size(); - mLedgersByIndex.eraseBefore(seq); - JLOG(j_.debug()) << "mLedgersByIndex size after clear: " - << mLedgersByIndex.size(); + std::size_t const indexesCleared = mLedgersByIndex.eraseBefore(seq); + JLOG(j_.debug()) << "LedgerIndexMap: cleared " << indexesCleared + << " index entries before seq " << seq << " (total now " + << mLedgersByIndex.size() << ")"; } } // namespace ripple