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")
View Source
var ErrNotFound = errors.New("blockstore: block not found")
View Source
var ValueTypeMismatch = errors.New("the retrieved value is not a Block")
Functions ¶
func NewBlockstore ¶
func NewBlockstore(d ds.Batching) *blockstore
func NewGCLocker ¶ added in v0.4.5
func NewGCLocker() *gclocker
Types ¶
type Blockstore ¶
type Blockstore interface {
DeleteBlock(*cid.Cid) error
Has(*cid.Cid) (bool, error)
Get(*cid.Cid) (blocks.Block, error)
Put(blocks.Block) error
PutMany([]blocks.Block) error
AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
}
Blockstore wraps a Datastore
func CachedBlockstore ¶ added in v0.4.3
func CachedBlockstore(bs Blockstore,
ctx context.Context, opts CacheOpts) (cbs Blockstore, err error)
type CacheOpts ¶ added in v0.4.3
type CacheOpts struct {
HasBloomFilterSize int // 1 byte
HasBloomFilterHashes int // No size, 7 is usually best, consult bloom papers
HasARCCacheSize int // 32 bytes
}
Next to each option is it aproximate memory usage per unit
func DefaultCacheOpts ¶ added in v0.4.3
func DefaultCacheOpts() CacheOpts
type GCBlockstore ¶ added in v0.4.0
type GCBlockstore interface {
Blockstore
GCLocker
}
func NewGCBlockstore ¶ added in v0.4.5
func NewGCBlockstore(bs Blockstore, gcl GCLocker) GCBlockstore
type GCLocker ¶ added in v0.4.5
type GCLocker interface {
// GCLock locks the blockstore for garbage collection. No operations
// that expect to finish with a pin should ocurr simultaneously.
// Reading during GC is safe, and requires no lock.
GCLock() Unlocker
// PinLock locks the blockstore for sequences of puts expected to finish
// with a pin (before GC). Multiple put->pin sequences can write through
// at the same time, but no GC should not happen simulatenously.
// Reading during Pinning is safe, and requires no lock.
PinLock() Unlocker
// GcRequested returns true if GCLock has been called and is waiting to
// take the lock
GCRequested() bool
}
Click to show internal directories.
Click to hide internal directories.