Documentation ¶
Overview ¶
stm: #unit
Index ¶
- Constants
- Variables
- type Blockstore
- func (b *Blockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (b *Blockstore) Close() error
- func (b *Blockstore) CollectGarbage(opts ...blockstore.BlockstoreGCOption) error
- func (b *Blockstore) DB() *badger.DB
- func (b *Blockstore) DeleteBlock(ctx context.Context, cid cid.Cid) error
- func (b *Blockstore) DeleteMany(ctx context.Context, cids []cid.Cid) error
- func (b *Blockstore) ForEachKey(f func(cid.Cid) error) error
- func (b *Blockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error)
- func (b *Blockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error)
- func (b *Blockstore) Has(ctx context.Context, cid cid.Cid) (bool, error)
- func (b *Blockstore) HashOnRead(_ bool)
- func (b *Blockstore) PooledStorageKey(cid cid.Cid) (key []byte, pooled bool)
- func (b *Blockstore) Put(ctx context.Context, block blocks.Block) error
- func (b *Blockstore) PutMany(ctx context.Context, blocks []blocks.Block) error
- func (b *Blockstore) Size() (int64, error)
- func (b *Blockstore) StorageKey(dst []byte, cid cid.Cid) []byte
- func (b *Blockstore) View(ctx context.Context, cid cid.Cid, fn func([]byte) error) error
- type Options
- type Suite
- func (s *Suite) RunTests(t *testing.T, prefix string)
- func (s *Suite) TestAllKeysRespectsContext(t *testing.T)
- func (s *Suite) TestAllKeysSimple(t *testing.T)
- func (s *Suite) TestCidv0v1(t *testing.T)
- func (s *Suite) TestDelete(t *testing.T)
- func (s *Suite) TestDoubleClose(t *testing.T)
- func (s *Suite) TestGetWhenKeyIsNil(t *testing.T)
- func (s *Suite) TestGetWhenKeyNotPresent(t *testing.T)
- func (s *Suite) TestHas(t *testing.T)
- func (s *Suite) TestPutMany(t *testing.T)
- func (s *Suite) TestPutThenGetBlock(t *testing.T)
- func (s *Suite) TestPutThenGetSizeBlock(t *testing.T)
- func (s *Suite) TestReopenPutGet(t *testing.T)
Constants ¶
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 ¶
var ( // ErrBlockstoreClosed is returned from blockstore operations after // the blockstore has been closed. ErrBlockstoreClosed = fmt.Errorf("badger blockstore closed") )
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) 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) 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.
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 ¶
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.