blockstore

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: Apache-2.0, MIT Imports: 6 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 DefaultCacheOpts = blockstore.DefaultCacheOpts
View Source
var ErrNotFound = blockstore.ErrNotFound
View Source
var NewGCBlockstore = blockstore.NewGCBlockstore
View Source
var NewGCLocker = blockstore.NewGCLocker

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

type GCBlockstore

type GCBlockstore = blockstore.GCBlockstore

type GCLocker

type GCLocker = blockstore.GCLocker

type MemStore added in v0.10.2

type MemStore map[cid.Cid]blocks.Block

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.

type SyncStore added in v0.10.2

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

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.

Jump to

Keyboard shortcuts

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