@@ -32,19 +32,13 @@ type snapshotEntry struct {
3232const snapshotEntrySize = 16 // bytes per snapshotEntry
3333
3434// Cache tracks seen blocks and DA inclusion status using bounded LRU caches.
35- //
36- // Persistence: on every DA inclusion mutation a single snapshot key
37- // (storeKeyPrefix+"__snap") is rewritten with all current in-flight
38- // [blockHeight, daHeight] pairs. RestoreFromStore reads that one key on
39- // startup — O(1) regardless of chain length.
40- //
41- // After a restart, real content hashes are not available until the DA
42- // retriever re-fires. In the meantime, placeholder keys indexed by height
43- // allow lookups to succeed via getDAIncludedByHeight.
4435type Cache [T any ] struct {
36+ // itemsByHeight stores items keyed by uint64 height.
37+ // Mutex needed for atomic get-and-remove in getNextItem.
4538 itemsByHeight * lru.Cache [uint64 , * T ]
4639 itemsByHeightMu sync.Mutex
4740
41+ // hashes tracks whether a given hash has been seen
4842 hashes * lru.Cache [string , bool ]
4943
5044 // daIncluded maps hash → daHeight. Hash may be a real content hash or a
@@ -57,9 +51,11 @@ type Cache[T any] struct {
5751 hashByHeight * lru.Cache [uint64 , string ]
5852 hashByHeightMu sync.Mutex
5953
54+ // maxDAHeight tracks the maximum DA height seen
6055 maxDAHeight * atomic.Uint64
6156
62- store store.Store // nil = ephemeral, no persistence
57+ store store.Store // nil = ephemeral, no persistence
58+ // storeKeyPrefix is the prefix used for store keys
6359 storeKeyPrefix string
6460}
6561
0 commit comments