2021-07-09 16:19:37 +00:00
|
|
|
package blockstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io"
|
|
|
|
|
2022-06-15 10:06:22 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2023-01-26 15:41:28 +00:00
|
|
|
blocks "github.com/ipfs/go-libipfs/blocks"
|
2021-07-09 16:19:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ Blockstore = (*discardstore)(nil)
|
|
|
|
|
|
|
|
type discardstore struct {
|
|
|
|
bs Blockstore
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDiscardStore(bs Blockstore) Blockstore {
|
|
|
|
return &discardstore{bs: bs}
|
|
|
|
}
|
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
func (b *discardstore) Has(ctx context.Context, cid cid.Cid) (bool, error) {
|
|
|
|
return b.bs.Has(ctx, cid)
|
2021-07-09 16:19:37 +00:00
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
func (b *discardstore) HashOnRead(hor bool) {
|
|
|
|
b.bs.HashOnRead(hor)
|
2021-07-09 16:19:37 +00:00
|
|
|
}
|
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
func (b *discardstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error) {
|
|
|
|
return b.bs.Get(ctx, cid)
|
2021-07-09 16:19:37 +00:00
|
|
|
}
|
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
func (b *discardstore) GetSize(ctx context.Context, cid cid.Cid) (int, error) {
|
|
|
|
return b.bs.GetSize(ctx, cid)
|
2021-07-09 16:19:37 +00:00
|
|
|
}
|
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
func (b *discardstore) View(ctx context.Context, cid cid.Cid, f func([]byte) error) error {
|
|
|
|
return b.bs.View(ctx, cid, f)
|
2021-07-09 16:19:37 +00:00
|
|
|
}
|
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
func (b *discardstore) Put(ctx context.Context, blk blocks.Block) error {
|
2021-07-09 16:19:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
func (b *discardstore) PutMany(ctx context.Context, blks []blocks.Block) error {
|
2021-07-09 16:19:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
func (b *discardstore) DeleteBlock(ctx context.Context, cid cid.Cid) error {
|
2021-07-09 16:19:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-11-19 01:50:25 +00:00
|
|
|
func (b *discardstore) DeleteMany(ctx context.Context, cids []cid.Cid) error {
|
2021-07-09 16:19:37 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *discardstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
|
|
|
|
return b.bs.AllKeysChan(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *discardstore) Close() error {
|
|
|
|
if c, ok := b.bs.(io.Closer); ok {
|
|
|
|
return c.Close()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|