tvx: stores: implement View()

This commit is contained in:
Aayush 2022-11-07 16:38:50 -05:00
parent 8df5b81f24
commit ed83595e33

View File

@ -5,6 +5,8 @@ import (
"log"
"sync"
"golang.org/x/xerrors"
"github.com/fatih/color"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-blockservice"
@ -158,3 +160,12 @@ func (pb *proxyingBlockstore) PutMany(ctx context.Context, blocks []blocks.Block
pb.lk.Unlock()
return pb.Blockstore.PutMany(ctx, blocks)
}
func (pb *proxyingBlockstore) View(ctx context.Context, c cid.Cid, callback func([]byte) error) error {
blk, err := pb.Get(ctx, c)
if err != nil {
return xerrors.Errorf("failed to Get cid %s: %w", c, err)
}
return callback(blk.RawData())
}