Documentation ¶
Overview ¶
Package blockstore implements a thin wrapper over a datastore, giving a clean interface for Getting and Putting block objects.
Index ¶
- Variables
- func CachedBlockstore(ctx context.Context, bs ib.Blockstore, opts CacheOpts) (cbs ib.Blockstore, err error)
- func NewBlockstore(logger *zap.Logger, d ds.Batching) ib.Blockstore
- func NewGCBlockstore(bs ib.Blockstore, gcl ib.GCLocker) ib.GCBlockstore
- func NewGCLocker() ib.GCLocker
- func NewIdStore(bs ib.Blockstore) ib.Blockstore
- type Blockstore
- type CacheOpts
- type GCBlockstore
- type GCLocker
- type Unlocker
Constants ¶
This section is empty.
Variables ¶
var BlockPrefix = ds.NewKey("blocks")
BlockPrefix namespaces blockstore datastores
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.
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 ¶
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 ¶
NewGCLocker returns a default implementation of GCLocker using standard [RW] mutexes.
func NewIdStore ¶
func NewIdStore(bs ib.Blockstore) ib.Blockstore
Types ¶
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