fix TimedCacheBlockstore#View.

This commit is contained in:
Raúl Kripalani 2021-02-28 22:39:00 +00:00
parent 45a650c012
commit 853de3daf7

View File

@ -102,12 +102,14 @@ func (t *TimedCacheBlockstore) PutMany(bs []blocks.Block) error {
return t.active.PutMany(bs) return t.active.PutMany(bs)
} }
func (t *TimedCacheBlockstore) View(c cid.Cid, callback func([]byte) error) error { func (t *TimedCacheBlockstore) View(k cid.Cid, callback func([]byte) error) error {
blk, err := t.Get(c) t.mu.RLock()
if err != nil { defer t.mu.RUnlock()
return err err := t.active.View(k, callback)
if err == ErrNotFound {
err = t.inactive.View(k, callback)
} }
return callback(blk.RawData()) return err
} }
func (t *TimedCacheBlockstore) Get(k cid.Cid) (blocks.Block, error) { func (t *TimedCacheBlockstore) Get(k cid.Cid) (blocks.Block, error) {