diff --git a/internal/cache/in_memory.go b/internal/cache/in_memory.go index 35f45a78a..e410c71dd 100644 --- a/internal/cache/in_memory.go +++ b/internal/cache/in_memory.go @@ -20,7 +20,10 @@ func (s *MemoryStore) Get(key string) ([]byte, error) { return nil, ErrCacheNotFound } - bytes := value.([]byte) + bytes, ok := value.([]byte) + if !ok { + return nil, ErrCacheFailedToGet + } return bytes, nil } @@ -41,9 +44,16 @@ func (s *MemoryStore) Del(keys ...string) error { func (s *MemoryStore) GetAllWithPrefix(prefix string) (map[string][]byte, error) { keys := make(map[string][]byte) s.data.Range(func(k, v interface{}) bool { - key := k.(string) + key, ok := k.(string) + if !ok { + return false + } if key[:len(prefix)] == prefix { - keys[key] = v.([]byte) + value, ok := v.([]byte) + if !ok { + return false + } + keys[key] = value } return true }) diff --git a/internal/metamorph/processor_helpers.go b/internal/metamorph/processor_helpers.go index 2b47910a2..da4941867 100644 --- a/internal/metamorph/processor_helpers.go +++ b/internal/metamorph/processor_helpers.go @@ -101,7 +101,7 @@ func (p *Processor) getAllTransactionStatuses() (StatusUpdateMap, error) { func (p *Processor) clearCache(updateStatusMap StatusUpdateMap) error { keys := make([]string, len(updateStatusMap)) - for k, _ := range updateStatusMap { + for k := range updateStatusMap { keys = append(keys, CacheTxPrefix+k.String()) }