blockservice

package
v0.3.8-dev-trailers Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2015 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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