blockservice

package
v0.4.13-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2017 License: MIT Imports: 9 Imported by: 0

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

View Source
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

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.

func (*Session) GetBlock added in v0.4.11

func (s *Session) GetBlock(ctx context.Context, c *cid.Cid) (blocks.Block, error)

GetBlock gets a block in the context of a request session

func (*Session) GetBlocks added in v0.4.11

func (s *Session) GetBlocks(ctx context.Context, ks []*cid.Cid) <-chan blocks.Block

GetBlocks gets blocks in the context of a request session

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL