blockstore

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2020 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Overview

blockstore contains all the basic blockstore constructors used by lotus. Any blockstores not ultimately constructed out of the building blocks in this package may not work properly.

  • This package correctly wraps blockstores with the IdBlockstore. This blockstore:
  • Filters out all puts for blocks with CIDs using the "identity" hash function.
  • Extracts inlined blocks from CIDs using the identity hash function and returns them on get/has, ignoring the contents of the blockstore.
  • In the future, this package may enforce additional restrictions on block sizes, CID validity, etc.

To make auditing for misuse of blockstores tractable, this package re-exports parts of the go-ipfs-blockstore package such that no other package needs to import it directly.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = blockstore.ErrNotFound

Functions

func NewBlockstore

func NewBlockstore(dstore ds.Batching) blockstore.Blockstore

NewBlockstore creates a new blockstore wrapped by the given datastore.

func WrapIDStore

func WrapIDStore(bstore blockstore.Blockstore) blockstore.Blockstore

WrapIDStore wraps the underlying blockstore in an "identity" blockstore.

Types

type Blockstore

type Blockstore = blockstore.Blockstore

Alias so other packages don't have to import go-ipfs-blockstore

func CachedBlockstore

func CachedBlockstore(ctx context.Context, bs Blockstore, opts CacheOpts) (Blockstore, error)

type CacheOpts

type CacheOpts = blockstore.CacheOpts

func DefaultCacheOpts

func DefaultCacheOpts() CacheOpts

type FallbackStore added in v1.1.3

type FallbackStore struct {
	blockstore.Blockstore
	// contains filtered or unexported fields
}

func (*FallbackStore) Get added in v1.1.3

func (fbs *FallbackStore) Get(c cid.Cid) (blocks.Block, error)

func (*FallbackStore) GetSize added in v1.1.3

func (fbs *FallbackStore) GetSize(c cid.Cid) (int, error)

func (*FallbackStore) SetFallback added in v1.1.3

func (fbs *FallbackStore) SetFallback(fg func(context.Context, cid.Cid) (blocks.Block, error))

type MemStore added in v0.10.2

type MemStore map[cid.Cid]blocks.Block

MemStore is a terminal blockstore that keeps blocks in memory.

func NewTemporary

func NewTemporary() MemStore

NewTemporary returns a temporary blockstore.

func (MemStore) AllKeysChan added in v0.10.2

func (m MemStore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)

AllKeysChan returns a channel from which the CIDs in the Blockstore can be read. It should respect the given context, closing the channel if it becomes Done.

func (MemStore) DeleteBlock added in v0.10.2

func (m MemStore) DeleteBlock(k cid.Cid) error

func (MemStore) Get added in v0.10.2

func (m MemStore) Get(k cid.Cid) (blocks.Block, error)

func (MemStore) GetSize added in v0.10.2

func (m MemStore) GetSize(k cid.Cid) (int, error)

GetSize returns the CIDs mapped BlockSize

func (MemStore) Has added in v0.10.2

func (m MemStore) Has(k cid.Cid) (bool, error)

func (MemStore) HashOnRead added in v0.10.2

func (m MemStore) HashOnRead(enabled bool)

HashOnRead specifies if every read block should be rehashed to make sure it matches its CID.

func (MemStore) Put added in v0.10.2

func (m MemStore) Put(b blocks.Block) error

Put puts a given block to the underlying datastore

func (MemStore) PutMany added in v0.10.2

func (m MemStore) PutMany(bs []blocks.Block) error

PutMany puts a slice of blocks at the same time using batching capabilities of the underlying datastore whenever possible.

func (MemStore) View added in v1.1.3

func (m MemStore) View(k cid.Cid, callback func([]byte) error) error

type SyncStore added in v0.10.2

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

SyncStore is a terminal blockstore that is a synchronized version of MemStore.

func NewTemporarySync

func NewTemporarySync() *SyncStore

NewTemporarySync returns a thread-safe temporary blockstore.

func (*SyncStore) AllKeysChan added in v0.10.2

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

AllKeysChan returns a channel from which the CIDs in the Blockstore can be read. It should respect the given context, closing the channel if it becomes Done.

func (*SyncStore) DeleteBlock added in v0.10.2

func (m *SyncStore) DeleteBlock(k cid.Cid) error

func (*SyncStore) Get added in v0.10.2

func (m *SyncStore) Get(k cid.Cid) (blocks.Block, error)

func (*SyncStore) GetSize added in v0.10.2

func (m *SyncStore) GetSize(k cid.Cid) (int, error)

GetSize returns the CIDs mapped BlockSize

func (*SyncStore) Has added in v0.10.2

func (m *SyncStore) Has(k cid.Cid) (bool, error)

func (*SyncStore) HashOnRead added in v0.10.2

func (m *SyncStore) HashOnRead(enabled bool)

HashOnRead specifies if every read block should be rehashed to make sure it matches its CID.

func (*SyncStore) Put added in v0.10.2

func (m *SyncStore) Put(b blocks.Block) error

Put puts a given block to the underlying datastore

func (*SyncStore) PutMany added in v0.10.2

func (m *SyncStore) PutMany(bs []blocks.Block) error

PutMany puts a slice of blocks at the same time using batching capabilities of the underlying datastore whenever possible.

func (*SyncStore) View added in v1.1.3

func (m *SyncStore) View(k cid.Cid, callback func([]byte) error) error

type Viewer added in v1.1.3

type Viewer = blockstore.Viewer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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