blockstore

package module
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 19 Imported by: 0

README

go-ipfs-blockstore

go-ipfs-blockstore is a fork of ipfs/go-ipfs-blockstore tailored to the needs of TemporalX. List of changes:

  • Alias interfaces to upstream
  • Remove of GCBlockstore implementation, but left the alias for compatability
  • Implement logging with zap instead of ipfs/go-log
  • Use prometheus for metrics directly instead of go-ipfs-metrics
  • Adds an interface type for our reference counted blockstore

License

All previous code from upstream is licensed under MIT, while our new additions is licensed under AGPL-3.0; All AGPL-3.0 license code has a copyright header at the top of the file. For our actual license see LICENSE for upstream license see LICENSE.orig

Documentation

Overview

Package blockstore implements a thin wrapper over a datastore, giving a clean interface for Getting and Putting block objects, with added remote blockstore and metric tracking blockstore capabilities

Index

Constants

This section is empty.

Variables

View Source
var (

	// BlockPrefix namespaces blockstore datastores
	BlockPrefix = ib.BlockPrefix

	// ErrHashMismatch is an error returned when the hash of a block
	// is different than expected.
	ErrHashMismatch = ib.ErrHashMismatch

	// ErrNotFound is an error returned when a block is not found.
	ErrNotFound = ib.ErrNotFound
)

Functions

This section is empty.

Types

type Blockstore

type Blockstore = ib.Blockstore

Blockstore aliases upstream blockstore interface

type CacheOpts

type CacheOpts struct {
	HasBloomFilterSize   int // 1 byte
	HasBloomFilterHashes int // No size, 7 is usually best, consult bloom papers
	HasARCCacheSize      int // 32 bytes
}

CacheOpts wraps options for CachedBlockStore(). Next to each option is it aproximate memory usage per unit

func DefaultCacheOpts

func DefaultCacheOpts() CacheOpts

DefaultCacheOpts returns a CacheOpts initialized with default values.

type CountedBlockstore added in v2.1.1

type CountedBlockstore interface {
	CollectGarbage() error
	GetRefCount(cid.Cid) (int64, error)
	Close() error
	Blockstore
}

CountedBlockstore is a reference counted blockstore

type GCBlockstore

type GCBlockstore = ib.GCBlockstore

GCBlockstore aliases upstream gcblockstore interface

type GCLocker

type GCLocker = ib.GCLocker

GCLocker aliases upstream gclocker interface

type MetricStore added in v2.1.4

type MetricStore interface {
	Blockstore
	GetTotalBlocks() int64
}

MetricStore is a blockstore type that exposes functions to retrieve statistics about the blockstore

func CachedBlockstore

func CachedBlockstore(
	ctx context.Context,
	bs MetricStore,
	opts CacheOpts) (cbs MetricStore, err error)

CachedBlockstore returns a blockstore wrapped in an ARCCache and then in a bloom filter cache, if the options indicate it.

func NewBlockstore

func NewBlockstore(logger *zap.Logger, d ds.Batching) MetricStore

NewBlockstore returns a default Blockstore implementation using the provided datastore.Batching backend.

func NewIdStore

func NewIdStore(bs MetricStore) MetricStore

type RemoteBlockstore added in v2.1.0

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

RemoteBlockstore storing blocks in remote locations without running the blockstore locally. If behind latency sensitive networks, it is advisable to wrap this in a cached blockstore

func NewRemoteBlockstore added in v2.1.0

func NewRemoteBlockstore(ctx context.Context, logger *zap.Logger, xclient pb.NodeAPIClient) *RemoteBlockstore

NewRemoteBlockstore returns a new remote blockstore

func (*RemoteBlockstore) AllKeysChan added in v2.1.0

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

AllKeysChan is used to return all keys from the remote blockstore

func (*RemoteBlockstore) DeleteBlock added in v2.1.0

func (rbs *RemoteBlockstore) DeleteBlock(gocid cid.Cid) error

DeleteBlock is used to delete the block from the remote blockstore. This must be forced, as TemporalX does not allow "unforced" deletes

func (*RemoteBlockstore) Get added in v2.1.0

func (rbs *RemoteBlockstore) Get(gocid cid.Cid) (blocks.Block, error)

Get is used to retrieve a block from our blockstore

func (*RemoteBlockstore) GetSize added in v2.1.0

func (rbs *RemoteBlockstore) GetSize(gocid cid.Cid) (int, error)

GetSize returns the size of the block

func (*RemoteBlockstore) Has added in v2.1.0

func (rbs *RemoteBlockstore) Has(gocid cid.Cid) (bool, error)

Has is used to check whether or not we have the block

func (*RemoteBlockstore) HashOnRead added in v2.1.0

func (rbs *RemoteBlockstore) HashOnRead(enabled bool)

HashOnRead toggles hash on read

func (*RemoteBlockstore) Put added in v2.1.0

func (rbs *RemoteBlockstore) Put(block blocks.Block) error

Put allows putting blocks into the remote blockstore

func (*RemoteBlockstore) PutMany added in v2.1.0

func (rbs *RemoteBlockstore) PutMany(blocks []blocks.Block) error

PutMany allows putting many blocks into the remote blockstore

type Unlocker

type Unlocker = ib.Unlocker

Unlocker aliases upstream unlocker interface

Jump to

Keyboard shortcuts

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