Skip to content

Commit 34a7890

Browse files
committed
invalidate cache store data after pruning
1 parent 20d578b commit 34a7890

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

pkg/store/cached_store.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,19 @@ func (cs *CachedStore) Rollback(ctx context.Context, height uint64, aggregator b
157157
return nil
158158
}
159159

160+
// PruneBlocks wraps the underlying store's PruneBlocks and invalidates caches.
161+
// After pruning historical block data from disk, any cached entries for pruned
162+
// heights must not be served, so we conservatively clear the entire cache.
163+
func (cs *CachedStore) PruneBlocks(ctx context.Context, height uint64) error {
164+
if err := cs.Store.PruneBlocks(ctx, height); err != nil {
165+
return err
166+
}
167+
168+
// Invalidate cache for pruned heights
169+
cs.InvalidateRange(1, height)
170+
return nil
171+
}
172+
160173
// Close closes the underlying store.
161174
func (cs *CachedStore) Close() error {
162175
cs.ClearCache()

0 commit comments

Comments
 (0)