From 870a47f55d25dd0be3b16a0e94d2878fc7e8956b Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 9 Jul 2021 20:07:17 +0300 Subject: [PATCH] handle id cids in internal versions of view/get --- blockstore/splitstore/splitstore.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/blockstore/splitstore/splitstore.go b/blockstore/splitstore/splitstore.go index d6995e681..6a13be19c 100644 --- a/blockstore/splitstore/splitstore.go +++ b/blockstore/splitstore/splitstore.go @@ -1316,11 +1316,20 @@ 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 @@ -1328,6 +1337,10 @@ func (s *SplitStore) view(cid cid.Cid, cb func([]byte) error) error { } 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 {