Skip to content

Commit

Permalink
Rotate ledger headers if needed in SearchableBucketListSnapshot::getL…
Browse files Browse the repository at this point in the history
…edgerHeader
  • Loading branch information
marta-lokhova committed Sep 14, 2024
1 parent ba1d0d2 commit c3ad77e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/bucket/BucketListSnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions src/bucket/BucketListSnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ class SearchableBucketListSnapshot : public NonMovableOrCopyable
std::shared_ptr<EvictionStatistics> stats,
StateArchivalSettings const& sas);
uint32_t getLedgerSeq() const;
LedgerHeader const&
getLedgerHeader() const
{
return mSnapshot->getLedgerHeader();
}
LedgerHeader const& getLedgerHeader();
};
}
4 changes: 4 additions & 0 deletions src/ledger/LedgerStateSnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<AbstractLedgerStateSnapshot const> mGetter;
Expand Down

0 comments on commit c3ad77e

Please sign in to comment.