Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix committed Oct 15, 2024
1 parent fb4cdb6 commit fa45b5b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions disperser/batcher/encoding_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type EncodingStreamer struct {
// Used to keep track of the last evaluated key for fetching metadatas
exclusiveStartKey *disperser.BlobStoreExclusiveStartKey

operatorStateCache *lru.Cache[string, any]
operatorStateCache *lru.Cache[string, *core.IndexedOperatorState]
}

type batch struct {
Expand Down Expand Up @@ -116,7 +116,7 @@ func NewEncodingStreamer(
if config.EncodingQueueLimit <= 0 {
return nil, errors.New("EncodingQueueLimit should be greater than 0")
}
operatorStateCache, err := lru.New[string, any](operatorStateCacheSize)
operatorStateCache, err := lru.New[string, *core.IndexedOperatorState](operatorStateCacheSize)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -682,11 +682,7 @@ func (e *EncodingStreamer) getOperatorState(ctx context.Context, metadatas []*di

cacheKey := computeCacheKey(blockNumber, quorumIds)
if val, ok := e.operatorStateCache.Get(cacheKey); ok {
state, ok := val.(*core.IndexedOperatorState)
if !ok {
return nil, errors.New("cached value is not of type *core.IndexedOperatorState")
}
return state, nil
return val, nil
}
// GetIndexedOperatorState should return state for valid quorums only
state, err := e.chainState.GetIndexedOperatorState(ctx, blockNumber, quorumIds)
Expand Down

0 comments on commit fa45b5b

Please sign in to comment.