Version: v0.4.0 Latest Latest

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

Go to latest
Published: Apr 7, 2016 License: MIT Imports: 7 Imported by: 0



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.



This section is empty.


View Source
var ErrNotFound = errors.New("blockservice: key not found")


This section is empty.


type BlockService

type BlockService struct {
	// TODO don't expose underlying impl details
	Blockstore blockstore.Blockstore
	Exchange   exchange.Interface

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 (*BlockService) AddBlock

func (s *BlockService) AddBlock(b *blocks.Block) (key.Key, error)

AddBlock adds a particular block to the service, Putting it into the datastore. TODO pass a context into this if the remote.HasBlock is going to remain here.

func (*BlockService) AddBlocks added in v0.3.6

func (s *BlockService) AddBlocks(bs []*blocks.Block) ([]key.Key, error)

func (*BlockService) Close

func (s *BlockService) Close() error

func (*BlockService) DeleteBlock

func (s *BlockService) DeleteBlock(k key.Key) error

DeleteBlock deletes a block in the blockservice from the datastore

func (*BlockService) GetBlock

func (s *BlockService) GetBlock(ctx context.Context, k key.Key) (*blocks.Block, error)

GetBlock retrieves a particular block from the service, Getting it from the datastore using the key (hash).

func (*BlockService) GetBlocks

func (s *BlockService) GetBlocks(ctx context.Context, ks []key.Key) <-chan *blocks.Block

GetBlocks gets a list of blocks asynchronously and returns through the returned channel. NB: No guarantees are made about order.

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL