tvx: stores: implement View()
This commit is contained in:
parent
8df5b81f24
commit
ed83595e33
@ -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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user