Documentation ¶
Overview ¶
blockstore contains all the basic blockstore constructors used by lotus. Any blockstores not ultimately constructed out of the building blocks in this package may not work properly.
- This package correctly wraps blockstores with the IdBlockstore. This blockstore:
- Filters out all puts for blocks with CIDs using the "identity" hash function.
- Extracts inlined blocks from CIDs using the identity hash function and returns them on get/has, ignoring the contents of the blockstore.
- In the future, this package may enforce additional restrictions on block sizes, CID validity, etc.
To make auditing for misuse of blockstores tractable, this package re-exports parts of the go-ipfs-blockstore package such that no other package needs to import it directly.
Index ¶
- Variables
- func NewBlockstore(dstore ds.Batching) blockstore.Blockstore
- func WrapIDStore(bstore blockstore.Blockstore) blockstore.Blockstore
- type Blockstore
- type CacheOpts
- type FallbackStore
- type MemStore
- func (m MemStore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (m MemStore) DeleteBlock(k cid.Cid) error
- func (m MemStore) Get(k cid.Cid) (blocks.Block, error)
- func (m MemStore) GetSize(k cid.Cid) (int, error)
- func (m MemStore) Has(k cid.Cid) (bool, error)
- func (m MemStore) HashOnRead(enabled bool)
- func (m MemStore) Put(b blocks.Block) error
- func (m MemStore) PutMany(bs []blocks.Block) error
- func (m MemStore) View(k cid.Cid, callback func([]byte) error) error
- type SyncStore
- func (m *SyncStore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error)
- func (m *SyncStore) DeleteBlock(k cid.Cid) error
- func (m *SyncStore) Get(k cid.Cid) (blocks.Block, error)
- func (m *SyncStore) GetSize(k cid.Cid) (int, error)
- func (m *SyncStore) Has(k cid.Cid) (bool, error)
- func (m *SyncStore) HashOnRead(enabled bool)
- func (m *SyncStore) Put(b blocks.Block) error
- func (m *SyncStore) PutMany(bs []blocks.Block) error
- func (m *SyncStore) View(k cid.Cid, callback func([]byte) error) error
- type Viewer
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = blockstore.ErrNotFound
Functions ¶
func NewBlockstore ¶
func NewBlockstore(dstore ds.Batching) blockstore.Blockstore
NewBlockstore creates a new blockstore wrapped by the given datastore.
func WrapIDStore ¶
func WrapIDStore(bstore blockstore.Blockstore) blockstore.Blockstore
WrapIDStore wraps the underlying blockstore in an "identity" blockstore.
Types ¶
type Blockstore ¶
type Blockstore = blockstore.Blockstore
Alias so other packages don't have to import go-ipfs-blockstore
func CachedBlockstore ¶
func CachedBlockstore(ctx context.Context, bs Blockstore, opts CacheOpts) (Blockstore, error)
type CacheOpts ¶
type CacheOpts = blockstore.CacheOpts
func DefaultCacheOpts ¶
func DefaultCacheOpts() CacheOpts
type FallbackStore ¶ added in v1.1.3
type FallbackStore struct { blockstore.Blockstore // contains filtered or unexported fields }
func (*FallbackStore) Get ¶ added in v1.1.3
func (fbs *FallbackStore) Get(c cid.Cid) (blocks.Block, error)
func (*FallbackStore) GetSize ¶ added in v1.1.3
func (fbs *FallbackStore) GetSize(c cid.Cid) (int, error)
func (*FallbackStore) SetFallback ¶ added in v1.1.3
type MemStore ¶ added in v0.10.2
MemStore is a terminal blockstore that keeps blocks in memory.
func (MemStore) AllKeysChan ¶ added in v0.10.2
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.
func (MemStore) DeleteBlock ¶ added in v0.10.2
func (MemStore) HashOnRead ¶ added in v0.10.2
HashOnRead specifies if every read block should be rehashed to make sure it matches its CID.
type SyncStore ¶ added in v0.10.2
type SyncStore struct {
// contains filtered or unexported fields
}
SyncStore is a terminal blockstore that is a synchronized version of MemStore.
func NewTemporarySync ¶
func NewTemporarySync() *SyncStore
NewTemporarySync returns a thread-safe temporary blockstore.
func (*SyncStore) AllKeysChan ¶ added in v0.10.2
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.
func (*SyncStore) DeleteBlock ¶ added in v0.10.2
func (*SyncStore) HashOnRead ¶ added in v0.10.2
HashOnRead specifies if every read block should be rehashed to make sure it matches its CID.
type Viewer ¶ added in v1.1.3
type Viewer = blockstore.Viewer