this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

util: remove tierbs and ReadThroughBstore

-85
-85
util/tierbs.go
··· 1 - package util 2 - 3 - import ( 4 - "context" 5 - "fmt" 6 - 7 - blockformat "github.com/ipfs/go-block-format" 8 - "github.com/ipfs/go-cid" 9 - blockstore "github.com/ipfs/go-ipfs-blockstore" 10 - ipld "github.com/ipfs/go-ipld-format" 11 - ) 12 - 13 - type ReadThroughBstore struct { 14 - base blockstore.Blockstore 15 - fresh blockstore.Blockstore 16 - } 17 - 18 - func NewReadThroughBstore(base, fresh blockstore.Blockstore) *ReadThroughBstore { 19 - return &ReadThroughBstore{ 20 - base: base, 21 - fresh: fresh, 22 - } 23 - } 24 - 25 - var _ blockstore.Blockstore = (*ReadThroughBstore)(nil) 26 - 27 - func (bs *ReadThroughBstore) DeleteBlock(ctx context.Context, c cid.Cid) error { 28 - return bs.fresh.DeleteBlock(ctx, c) 29 - 30 - } 31 - 32 - func (bs *ReadThroughBstore) Has(ctx context.Context, c cid.Cid) (bool, error) { 33 - h, err := bs.fresh.Has(ctx, c) 34 - if err != nil { 35 - return false, err 36 - } 37 - 38 - if h { 39 - return true, nil 40 - } 41 - 42 - return bs.base.Has(ctx, c) 43 - } 44 - 45 - func (bs *ReadThroughBstore) Get(ctx context.Context, c cid.Cid) (blockformat.Block, error) { 46 - blk, err := bs.fresh.Get(ctx, c) 47 - if err == nil { 48 - return blk, nil 49 - } 50 - 51 - if !ipld.IsNotFound(err) { 52 - return nil, err 53 - } 54 - 55 - return bs.base.Get(ctx, c) 56 - } 57 - 58 - func (bs *ReadThroughBstore) GetSize(ctx context.Context, c cid.Cid) (int, error) { 59 - size, err := bs.fresh.GetSize(ctx, c) 60 - if err == nil { 61 - return size, nil 62 - } 63 - 64 - if !ipld.IsNotFound(err) { 65 - return -1, err 66 - } 67 - 68 - return bs.base.GetSize(ctx, c) 69 - } 70 - 71 - func (bs *ReadThroughBstore) Put(context.Context, blockformat.Block) error { 72 - return fmt.Errorf("writes not allows on readthrough blockstore") 73 - } 74 - 75 - func (bs *ReadThroughBstore) PutMany(context.Context, []blockformat.Block) error { 76 - return fmt.Errorf("writes not allows on readthrough blockstore") 77 - } 78 - 79 - func (bs *ReadThroughBstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) { 80 - return nil, fmt.Errorf("iteration not supported on readthrough blockstore") 81 - } 82 - 83 - func (bs *ReadThroughBstore) HashOnRead(enabled bool) { 84 - 85 - }