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 ¶
- Variables
- type Blockstore
- type CacheOpts
- type CountedBlockstore
- type GCBlockstore
- type GCLocker
- type MetricStore
- type RemoteBlockstore
- func (rbs *RemoteBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (rbs *RemoteBlockstore) DeleteBlock(gocid cid.Cid) error
- func (rbs *RemoteBlockstore) Get(gocid cid.Cid) (blocks.Block, error)
- func (rbs *RemoteBlockstore) GetSize(gocid cid.Cid) (int, error)
- func (rbs *RemoteBlockstore) Has(gocid cid.Cid) (bool, error)
- func (rbs *RemoteBlockstore) HashOnRead(enabled bool)
- func (rbs *RemoteBlockstore) Put(block blocks.Block) error
- func (rbs *RemoteBlockstore) PutMany(blocks []blocks.Block) error
- type Unlocker
Constants ¶
This section is empty.
Variables ¶
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 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 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
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) 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