blockservice

package
v0.0.0-...-3c4b020 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 8 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 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) 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
package exchange defines the IPFS Exchange interface this is here to avoid vendoring IPFS for now.
package exchange defines the IPFS Exchange interface this is here to avoid vendoring IPFS for now.
offline
package offline implements an object that implements the exchange interface but returns nil values to every request.
package offline implements an object that implements the exchange interface but returns nil values to every request.
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