blockservice

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2015 License: MIT Imports: 13 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 struct {
	// TODO don't expose underlying impl details
	Blockstore blockstore.Blockstore
	Exchange   exchange.Interface
	// contains filtered or unexported fields
}

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 Mocks

func Mocks(t *testing.T, n int) []*BlockService

Mocks returns |n| connected mock Blockservices

func New

NewBlockService creates a BlockService with given datastore instance.

func (*BlockService) AddBlock

func (s *BlockService) AddBlock(b *blocks.Block) (u.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) Close

func (s *BlockService) Close() error

func (*BlockService) DeleteBlock

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

DeleteBlock deletes a block in the blockservice from the datastore

func (*BlockService) GetBlock

func (s *BlockService) GetBlock(ctx context.Context, k u.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 []u.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
TODO FIXME name me
TODO FIXME name me

Jump to

Keyboard shortcuts

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