badgerbs

package
v1.20.0-hyperpsace-0119 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2023 License: Apache-2.0, MIT Imports: 24 Imported by: 9

Documentation

Overview

stm: #unit

Index

Constants

View Source
const (
	// FileIO is equivalent to badger/options.FileIO.
	FileIO = options.FileIO
	// MemoryMap is equivalent to badger/options.MemoryMap.
	MemoryMap = options.MemoryMap
	// LoadToRAM is equivalent to badger/options.LoadToRAM.
	LoadToRAM = options.LoadToRAM
)

aliases to mask badger dependencies.

Variables

View Source
var (
	// ErrBlockstoreClosed is returned from blockstore operations after
	// the blockstore has been closed.
	ErrBlockstoreClosed = fmt.Errorf("badger blockstore closed")
)
View Source
var (
	// KeyPool is the buffer pool we use to compute storage keys.
	KeyPool *pool.BufferPool = pool.GlobalPool
)

Functions

This section is empty.

Types

type Blockstore

type Blockstore struct {
	// contains filtered or unexported fields
}

Blockstore is a badger-backed IPLD blockstore.

func Open

func Open(opts Options) (*Blockstore, error)

Open creates a new badger-backed blockstore, with the supplied options.

func (*Blockstore) AllKeysChan

func (b *Blockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

AllKeysChan implements Blockstore.AllKeysChan.

func (*Blockstore) Close

func (b *Blockstore) Close() error

Close closes the store. If the store has already been closed, this noops and returns an error, even if the first closure resulted in error.

func (*Blockstore) CollectGarbage

func (b *Blockstore) CollectGarbage(opts ...blockstore.BlockstoreGCOption) error

CollectGarbage compacts and runs garbage collection on the value log; implements the BlockstoreGC trait

func (*Blockstore) DB

func (b *Blockstore) DB() *badger.DB

this method is added for lotus-shed needs WARNING: THIS IS COMPLETELY UNSAFE; DONT USE THIS IN PRODUCTION CODE

func (*Blockstore) DeleteBlock

func (b *Blockstore) DeleteBlock(ctx context.Context, cid cid.Cid) error

DeleteBlock implements Blockstore.DeleteBlock.

func (*Blockstore) DeleteMany

func (b *Blockstore) DeleteMany(ctx context.Context, cids []cid.Cid) error

func (*Blockstore) ForEachKey added in v1.11.1

func (b *Blockstore) ForEachKey(f func(cid.Cid) error) error

Implementation of BlockstoreIterator interface

func (*Blockstore) Get

func (b *Blockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)

Get implements Blockstore.Get.

func (*Blockstore) GetSize

func (b *Blockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error)

GetSize implements Blockstore.GetSize.

func (*Blockstore) Has

func (b *Blockstore) Has(ctx context.Context, cid cid.Cid) (bool, error)

Has implements Blockstore.Has.

func (*Blockstore) HashOnRead

func (b *Blockstore) HashOnRead(_ bool)

HashOnRead implements Blockstore.HashOnRead. It is not supported by this blockstore.

func (*Blockstore) PooledStorageKey

func (b *Blockstore) PooledStorageKey(cid cid.Cid) (key []byte, pooled bool)

PooledStorageKey returns the storage key under which this CID is stored.

The key is: prefix + base32_no_padding(cid.Hash)

This method may return pooled byte slice, which MUST be returned to the KeyPool if pooled=true, or a leak will occur.

func (*Blockstore) Put

func (b *Blockstore) Put(ctx context.Context, block blocks.Block) error

Put implements Blockstore.Put.

func (*Blockstore) PutMany

func (b *Blockstore) PutMany(ctx context.Context, blocks []blocks.Block) error

PutMany implements Blockstore.PutMany.

func (*Blockstore) Size added in v1.11.1

func (b *Blockstore) Size() (int64, error)

Size returns the aggregate size of the blockstore

func (*Blockstore) StorageKey

func (b *Blockstore) StorageKey(dst []byte, cid cid.Cid) []byte

Storage acts like PooledStorageKey, but attempts to write the storage key into the provided slice. If the slice capacity is insufficient, it allocates a new byte slice with enough capacity to accommodate the result. This method returns the resulting slice.

func (*Blockstore) View

func (b *Blockstore) View(ctx context.Context, cid cid.Cid, fn func([]byte) error) error

View implements blockstore.Viewer, which leverages zero-copy read-only access to values.

type Options

type Options struct {
	badger.Options

	// Prefix is an optional prefix to prepend to keys. Default: "".
	Prefix string
}

Options embeds the badger options themselves, and augments them with blockstore-specific options.

func DefaultOptions

func DefaultOptions(path string) Options

type Suite

type Suite struct {
	NewBlockstore  func(tb testing.TB) (bs blockstore.BasicBlockstore, path string)
	OpenBlockstore func(tb testing.TB, path string) (bs blockstore.BasicBlockstore, err error)
}

TODO: move this to go-ipfs-blockstore.

func (*Suite) RunTests

func (s *Suite) RunTests(t *testing.T, prefix string)

func (*Suite) TestAllKeysRespectsContext

func (s *Suite) TestAllKeysRespectsContext(t *testing.T)

func (*Suite) TestAllKeysSimple

func (s *Suite) TestAllKeysSimple(t *testing.T)

func (*Suite) TestCidv0v1

func (s *Suite) TestCidv0v1(t *testing.T)

func (*Suite) TestDelete

func (s *Suite) TestDelete(t *testing.T)

func (*Suite) TestDoubleClose

func (s *Suite) TestDoubleClose(t *testing.T)

func (*Suite) TestGetWhenKeyIsNil

func (s *Suite) TestGetWhenKeyIsNil(t *testing.T)

func (*Suite) TestGetWhenKeyNotPresent

func (s *Suite) TestGetWhenKeyNotPresent(t *testing.T)

func (*Suite) TestHas

func (s *Suite) TestHas(t *testing.T)

func (*Suite) TestPutMany

func (s *Suite) TestPutMany(t *testing.T)

func (*Suite) TestPutThenGetBlock

func (s *Suite) TestPutThenGetBlock(t *testing.T)

func (*Suite) TestPutThenGetSizeBlock

func (s *Suite) TestPutThenGetSizeBlock(t *testing.T)

func (*Suite) TestReopenPutGet

func (s *Suite) TestReopenPutGet(t *testing.T)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL