Documentation
¶
Overview ¶
Package blockstore implements a thin wrapper over a datastore, giving a clean interface for Getting and Putting block objects.
Index ¶
- Variables
- type Blockstoredeprecated
- type CacheOptsdeprecated
- func DefaultCacheOpts() CacheOptsdeprecated
- type GCBlockstoredeprecated
- type GCLockerdeprecated
- func NewGCLocker() GCLockerdeprecated
- type Optiondeprecated
- func NoPrefix() Optiondeprecated
- func WriteThrough() Optiondeprecated
- type Unlockerdeprecated
- type Viewerdeprecated
Constants ¶
This section is empty.
Variables ¶
var BlockPrefix = ds.NewKey("blocks")
BlockPrefix namespaces blockstore datastores
Deprecated: use github.com/ipfs/boxo/blockstore.BlockPrefix
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.
Deprecated: use github.com/ipfs/boxo/blockstore.ErrHashMismatch
Functions ¶
This section is empty.
Types ¶
type Blockstore
deprecated
type Blockstore interface {
DeleteBlock(context.Context, cid.Cid) error
Has(context.Context, cid.Cid) (bool, error)
Get(context.Context, cid.Cid) (blocks.Block, error)
// GetSize returns the CIDs mapped BlockSize
GetSize(context.Context, cid.Cid) (int, error)
// Put puts a given block to the underlying datastore
Put(context.Context, blocks.Block) error
// PutMany puts a slice of blocks at the same time using batching
// capabilities of the underlying datastore whenever possible.
PutMany(context.Context, []blocks.Block) 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.
AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
// HashOnRead specifies if every read block should be
// rehashed to make sure it matches its CID.
HashOnRead(enabled bool)
}
Blockstore wraps a Datastore block-centered methods and provides a layer of abstraction which allows to add different caching strategies.
Deprecated: use github.com/ipfs/boxo/blockstore.Blockstore
func CachedBlockstore
deprecated
func CachedBlockstore( ctx context.Context, bs Blockstore, opts CacheOpts) (cbs Blockstore, err error)
CachedBlockstore returns a blockstore wrapped in an ARCCache and then in a bloom filter cache, if the options indicate it.
Deprecated: use github.com/ipfs/boxo/blockstore.CachedBlockstore
func NewBlockstore
deprecated
func NewBlockstore(d ds.Batching, opts ...Option) Blockstore
NewBlockstore returns a default Blockstore implementation using the provided datastore.Batching backend.
Deprecated: use github.com/ipfs/boxo/blockstore.NewBlockstore
func NewBlockstoreNoPrefix
deprecated
added in
v1.1.0
func NewBlockstoreNoPrefix(d ds.Batching) Blockstore
NewBlockstoreNoPrefix returns a default Blockstore implementation using the provided datastore.Batching backend. This constructor does not modify input keys in any way
Deprecated: Use NewBlockstore with the NoPrefix option instead.
Deprecated: use github.com/ipfs/boxo/blockstore.NewBlockstoreNoPrefix
func NewIdStore
deprecated
func NewIdStore(bs Blockstore) Blockstore
Deprecated: use github.com/ipfs/boxo/blockstore.NewIdStore
type CacheOpts
deprecated
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
Deprecated: use github.com/ipfs/boxo/blockstore.CacheOpts
func DefaultCacheOpts
deprecated
func DefaultCacheOpts() CacheOpts
DefaultCacheOpts returns a CacheOpts initialized with default values.
Deprecated: use github.com/ipfs/boxo/blockstore.DefaultCacheOpts
type GCBlockstore
deprecated
type GCBlockstore interface {
Blockstore
GCLocker
}
GCBlockstore is a blockstore that can safely run garbage-collection operations.
Deprecated: use github.com/ipfs/boxo/blockstore.GCBlockstore
func NewGCBlockstore
deprecated
func NewGCBlockstore(bs Blockstore, gcl GCLocker) GCBlockstore
NewGCBlockstore returns a default implementation of GCBlockstore using the given Blockstore and GCLocker.
Deprecated: use github.com/ipfs/boxo/blockstore.NewGCBlockstore
type GCLocker
deprecated
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(context.Context) 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 happen simulatenously.
// Reading during Pinning is safe, and requires no lock.
PinLock(context.Context) Unlocker
// GcRequested returns true if GCLock has been called and is waiting to
// take the lock
GCRequested(context.Context) bool
}
GCLocker abstract functionality to lock a blockstore when performing garbage-collection operations.
Deprecated: use github.com/ipfs/boxo/blockstore.GCLocker
func NewGCLocker
deprecated
func NewGCLocker() GCLocker
NewGCLocker returns a default implementation of GCLocker using standard [RW] mutexes.
Deprecated: use github.com/ipfs/boxo/blockstore.NewGCLocker
type Option
deprecated
added in
v1.3.0
type Option struct {
// contains filtered or unexported fields
}
Option is a default implementation Blockstore option
Deprecated: use github.com/ipfs/boxo/blockstore.Option
func WriteThrough
deprecated
added in
v1.3.0
func WriteThrough() Option
WriteThrough skips checking if the blockstore already has a block before writing it.
Deprecated: use github.com/ipfs/boxo/blockstore.WriteThrough
type Viewer
deprecated
added in
v1.0.2
Viewer can be implemented by blockstores that offer zero-copy access to values.
Callers of View must not mutate or retain the byte slice, as it could be an mmapped memory region, or a pooled byte buffer.
View is especially suitable for deserialising in place.
The callback will only be called iff the query operation is successful (and the block is found); otherwise, the error will be propagated. Errors returned by the callback will be propagated as well.
Deprecated: use github.com/ipfs/boxo/blockstore.Viewer