blockstore

package module
v3.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: MIT Imports: 18 Imported by: 0

README

go-ipfs-blockstore

standard-readme compliant GoDoc Build Status

go-ipfs-blockstore implements a thin wrapper over a datastore, giving a clean interface for Getting and Putting block objects.

Lead Maintainer

Steven Allen

Table of Contents

Install

go-ipfs-blockstore works like a regular Go module:

> go get github.com/ipfs/go-ipfs-blockstore

Usage

import "github.com/ipfs/go-ipfs-blockstore"

Check the GoDoc documentation

Contribute

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © Protocol Labs, Inc.

Documentation

Overview

Package blockstore implements a thin wrapper over a datastore, giving a clean interface for Getting and Putting block objects.

Index

Constants

This section is empty.

Variables

View Source
var BlockPrefix = ds.NewKey("blocks")

BlockPrefix namespaces blockstore datastores

View Source
var ErrHashMismatch = errors.New("block in storage has different hash than requested")

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

View Source
var ErrNotFound = errors.New("blockstore: block not found")

ErrNotFound is an error returned when a block is not found.

Functions

func CachedBlockstore

func CachedBlockstore(
	ctx context.Context,
	bs ib.Blockstore,
	opts CacheOpts) (cbs ib.Blockstore, 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) ib.Blockstore

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

func NewGCBlockstore

func NewGCBlockstore(bs ib.Blockstore, gcl ib.GCLocker) ib.GCBlockstore

NewGCBlockstore returns a default implementation of GCBlockstore using the given Blockstore and GCLocker.

func NewGCLocker

func NewGCLocker() ib.GCLocker

NewGCLocker returns a default implementation of GCLocker using standard [RW] mutexes.

func NewIdStore

func NewIdStore(bs ib.Blockstore) ib.Blockstore

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 GCBlockstore

type GCBlockstore ib.GCBlockstore

GCBlockstore aliases upstream gcblockstore interface

type GCLocker

type GCLocker ib.GCLocker

GCLocker aliases upstream gclocker interface

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