Skip to content

Commit

Permalink
use generic constructor in store
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Aug 20, 2023
1 parent 755b8a9 commit c5eec82
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,21 @@ func (s *Store[H]) Get(ctx context.Context, hash header.Hash) (H, error) {

b, err := s.ds.Get(ctx, datastore.NewKey(hash.String()))
if err != nil {
if err == datastore.ErrNotFound {
if errors.Is(err, datastore.ErrNotFound) {
return zero, header.ErrNotFound
}

return zero, err
}

var empty H
h := empty.New()
h := header.New[H]()
err = h.UnmarshalBinary(b)
if err != nil {
return zero, err
}

s.cache.Add(h.Hash().String(), h)
return h.(H), nil
return h, nil
}

func (s *Store[H]) GetByHeight(ctx context.Context, height uint64) (H, error) {
Expand Down

0 comments on commit c5eec82

Please sign in to comment.