diff --git a/src/bucket/BucketListSnapshot.cpp b/src/bucket/BucketListSnapshot.cpp index e5adfb56bb..5d26fd8296 100644 --- a/src/bucket/BucketListSnapshot.cpp +++ b/src/bucket/BucketListSnapshot.cpp @@ -127,6 +127,14 @@ SearchableBucketListSnapshot::getLedgerSeq() const return mSnapshot->getLedgerSeq(); } +LedgerHeader const& +SearchableBucketListSnapshot::getLedgerHeader() +{ + releaseAssert(mSnapshot); + mSnapshotManager.maybeUpdateSnapshot(mSnapshot, mHistoricalSnapshots); + return mSnapshot->getLedgerHeader(); +} + EvictionResult SearchableBucketListSnapshot::scanForEviction( uint32_t ledgerSeq, EvictionCounters& counters, diff --git a/src/bucket/BucketListSnapshot.h b/src/bucket/BucketListSnapshot.h index 9b6fd5dcf8..ea14869f3a 100644 --- a/src/bucket/BucketListSnapshot.h +++ b/src/bucket/BucketListSnapshot.h @@ -102,10 +102,6 @@ class SearchableBucketListSnapshot : public NonMovableOrCopyable std::shared_ptr stats, StateArchivalSettings const& sas); uint32_t getLedgerSeq() const; - LedgerHeader const& - getLedgerHeader() const - { - return mSnapshot->getLedgerHeader(); - } + LedgerHeader const& getLedgerHeader(); }; } \ No newline at end of file diff --git a/src/ledger/LedgerStateSnapshot.h b/src/ledger/LedgerStateSnapshot.h index d60e5eb1ae..7a57b1c771 100644 --- a/src/ledger/LedgerStateSnapshot.h +++ b/src/ledger/LedgerStateSnapshot.h @@ -130,6 +130,10 @@ class BucketSnapshotState : public AbstractLedgerStateSnapshot // A helper class to create and query read-only snapshots // Automatically decides whether to create a BucketList (recommended), or SQL // snapshot (deprecated, but currently supported) +// NOTE: LedgerSnapshot is meant to be short-lived, and should not be persisted +// across _different_ ledgers, as the state under the hood might change. Users +// are expected to construct a new LedgerSnapshot each time they want to query +// ledger state. class LedgerSnapshot : public NonMovableOrCopyable { std::unique_ptr mGetter;