Skip to content

Commit 0e9f5be

Browse files
committed
simplify getmetadata
1 parent c19dc02 commit 0e9f5be

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

block/internal/cache/generic_cache.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,10 @@ func (c *Cache[T]) RestoreFromStore(ctx context.Context) error {
230230

231231
for _, entry := range entries {
232232
// Extract the hash from the key by removing the prefix
233-
// The key may have a leading "/" so we try both formats
234233
hash := strings.TrimPrefix(entry.Key, c.storeKeyPrefix)
235-
if hash == entry.Key {
236-
// Try with leading slash
237-
hash = strings.TrimPrefix(entry.Key, "/"+c.storeKeyPrefix)
238-
}
239-
if hash == "" || hash == entry.Key {
240-
continue // Invalid key format
234+
if hash == entry.Key || hash == "" {
235+
// Prefix not found or empty hash - skip invalid entry
236+
continue
241237
}
242238

243239
daHeight, blockHeight, ok := decodeDAInclusion(entry.Value)

pkg/store/store.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ func (s *DefaultStore) GetMetadataByPrefix(ctx context.Context, prefix string) (
215215
// We want to return "cache/header-da-included/hash"
216216
metaKeyPrefix := getMetaKey("")
217217
key := strings.TrimPrefix(result.Key, metaKeyPrefix)
218+
key = strings.TrimPrefix(key, "/") // Remove leading slash for consistency
218219

219220
entries = append(entries, MetadataEntry{
220221
Key: key,

0 commit comments

Comments
 (0)