Skip to content

Commit

Permalink
handle id cids in internal versions of view/get
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Jul 9, 2021
1 parent f5ae10e commit 870a47f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1316,18 +1316,31 @@ func (s *SplitStore) walkObjectIncomplete(c cid.Cid, walked *cid.Set, f, missing
}

// internal version used by walk
func (s *SplitStore) view(cid cid.Cid, cb func([]byte) error) error {
err := s.hot.View(cid, cb)
func (s *SplitStore) view(c cid.Cid, cb func([]byte) error) error {
if isIdentiyCid(c) {
data, err := decodeIdentityCid(c)
if err != nil {
return err
}

return cb(data)
}

err := s.hot.View(c, cb)
switch err {
case bstore.ErrNotFound:
return s.cold.View(cid, cb)
return s.cold.View(c, cb)

default:
return err
}
}

func (s *SplitStore) has(c cid.Cid) (bool, error) {
if isIdentiyCid(c) {
return true, nil
}

has, err := s.hot.Has(c)

if has || err != nil {
Expand Down

0 comments on commit 870a47f

Please sign in to comment.