Documentation ¶
Overview ¶
package blockservice implements a BlockService interface that provides a single GetBlock/AddBlock interface that seamlessly retrieves data either locally or from a remote peer through the exchange.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("blockservice: key not found")
Functions ¶
This section is empty.
Types ¶
type BlockService ¶
type BlockService interface { Blockstore() blockstore.Blockstore Exchange() exchange.Interface AddBlock(o blocks.Block) (*cid.Cid, error) AddBlocks(bs []blocks.Block) ([]*cid.Cid, error) GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error) GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block DeleteBlock(o blocks.Block) error Close() error }
BlockService is a hybrid block datastore. It stores data in a local datastore and may retrieve data from a remote Exchange. It uses an internal `datastore.Datastore` instance to store values.
func New ¶
func New(bs blockstore.Blockstore, rem exchange.Interface) BlockService
NewBlockService creates a BlockService with given datastore instance.
func NewWriteThrough ¶ added in v0.4.5
func NewWriteThrough(bs blockstore.Blockstore, rem exchange.Interface) BlockService
NewWriteThrough ceates a BlockService that guarantees writes will go through to the blockstore and are not skipped by cache checks.
type Session ¶ added in v0.4.11
type Session struct {
// contains filtered or unexported fields
}
Session is a helper type to provide higher level access to bitswap sessions
func NewSession ¶ added in v0.4.11
func NewSession(ctx context.Context, bs BlockService) *Session
NewSession creates a bitswap session that allows for controlled exchange of wantlists to decrease the bandwidth overhead.