rename noopstore to discardstore
This commit is contained in:
parent
18161fee38
commit
c0a1cfffa1
66
blockstore/discard.go
Normal file
66
blockstore/discard.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package blockstore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
blocks "github.com/ipfs/go-block-format"
|
||||||
|
cid "github.com/ipfs/go-cid"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ Blockstore = (*discardstore)(nil)
|
||||||
|
|
||||||
|
type discardstore struct {
|
||||||
|
bs Blockstore
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDiscardStore(bs Blockstore) Blockstore {
|
||||||
|
return &discardstore{bs: bs}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) Has(cid cid.Cid) (bool, error) {
|
||||||
|
return b.bs.Has(cid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) HashOnRead(hor bool) {
|
||||||
|
b.bs.HashOnRead(hor)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) Get(cid cid.Cid) (blocks.Block, error) {
|
||||||
|
return b.bs.Get(cid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) GetSize(cid cid.Cid) (int, error) {
|
||||||
|
return b.bs.GetSize(cid)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) View(cid cid.Cid, f func([]byte) error) error {
|
||||||
|
return b.bs.View(cid, f)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) Put(blk blocks.Block) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) PutMany(blks []blocks.Block) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) DeleteBlock(cid cid.Cid) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *discardstore) DeleteMany(cids []cid.Cid) error {
|
||||||
|
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
|
||||||
|
}
|
@ -1,66 +0,0 @@
|
|||||||
package blockstore
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"io"
|
|
||||||
|
|
||||||
blocks "github.com/ipfs/go-block-format"
|
|
||||||
cid "github.com/ipfs/go-cid"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ Blockstore = (*noopstore)(nil)
|
|
||||||
|
|
||||||
type noopstore struct {
|
|
||||||
bs Blockstore
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNoopStore(bs Blockstore) Blockstore {
|
|
||||||
return &noopstore{bs: bs}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) Has(cid cid.Cid) (bool, error) {
|
|
||||||
return b.bs.Has(cid)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) HashOnRead(hor bool) {
|
|
||||||
b.bs.HashOnRead(hor)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) Get(cid cid.Cid) (blocks.Block, error) {
|
|
||||||
return b.bs.Get(cid)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) GetSize(cid cid.Cid) (int, error) {
|
|
||||||
return b.bs.GetSize(cid)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) View(cid cid.Cid, f func([]byte) error) error {
|
|
||||||
return b.bs.View(cid, f)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) Put(blk blocks.Block) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) PutMany(blks []blocks.Block) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) DeleteBlock(cid cid.Cid) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) DeleteMany(cids []cid.Cid) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
|
|
||||||
return b.bs.AllKeysChan(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *noopstore) Close() error {
|
|
||||||
if c, ok := b.bs.(io.Closer); ok {
|
|
||||||
return c.Close()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -645,8 +645,8 @@ func Repo(r repo.Repo) Option {
|
|||||||
If(cfg.EnableSplitstore,
|
If(cfg.EnableSplitstore,
|
||||||
If(cfg.Splitstore.ColdStoreType == "universal",
|
If(cfg.Splitstore.ColdStoreType == "universal",
|
||||||
Override(new(dtypes.ColdBlockstore), From(new(dtypes.UniversalBlockstore)))),
|
Override(new(dtypes.ColdBlockstore), From(new(dtypes.UniversalBlockstore)))),
|
||||||
If(cfg.Splitstore.ColdStoreType == "noop",
|
If(cfg.Splitstore.ColdStoreType == "discard",
|
||||||
Override(new(dtypes.ColdBlockstore), modules.NoopColdBlockstore)),
|
Override(new(dtypes.ColdBlockstore), modules.DiscardColdBlockstore)),
|
||||||
If(cfg.Splitstore.HotStoreType == "badger",
|
If(cfg.Splitstore.HotStoreType == "badger",
|
||||||
Override(new(dtypes.HotBlockstore), modules.BadgerHotBlockstore)),
|
Override(new(dtypes.HotBlockstore), modules.BadgerHotBlockstore)),
|
||||||
Override(new(dtypes.SplitBlockstore), modules.SplitBlockstore(cfg)),
|
Override(new(dtypes.SplitBlockstore), modules.SplitBlockstore(cfg)),
|
||||||
|
@ -37,8 +37,8 @@ func UniversalBlockstore(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.Locked
|
|||||||
return bs, err
|
return bs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func NoopColdBlockstore(lc fx.Lifecycle, bs dtypes.UniversalBlockstore) (dtypes.ColdBlockstore, error) {
|
func DiscardColdBlockstore(lc fx.Lifecycle, bs dtypes.UniversalBlockstore) (dtypes.ColdBlockstore, error) {
|
||||||
return blockstore.NewNoopStore(bs), nil
|
return blockstore.NewDiscardStore(bs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func BadgerHotBlockstore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.HotBlockstore, error) {
|
func BadgerHotBlockstore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.HotBlockstore, error) {
|
||||||
@ -79,7 +79,7 @@ func SplitBlockstore(cfg *config.Chainstore) func(lc fx.Lifecycle, r repo.Locked
|
|||||||
|
|
||||||
cfg := &splitstore.Config{
|
cfg := &splitstore.Config{
|
||||||
MarkSetType: cfg.Splitstore.MarkSetType,
|
MarkSetType: cfg.Splitstore.MarkSetType,
|
||||||
DiscardColdBlocks: cfg.Splitstore.ColdStoreType == "noop",
|
DiscardColdBlocks: cfg.Splitstore.ColdStoreType == "discard",
|
||||||
}
|
}
|
||||||
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
|
ss, err := splitstore.Open(path, ds, hot, cold, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user