 Documentation
      ¶
      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 ¶
- Variables
- type BlockService
- func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error)
- func (s *BlockService) Close() error
- func (s *BlockService) DeleteBlock(k u.Key) error
- func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, error)
- func (s *BlockService) GetBlocks(ctx context.Context, ks []u.Key) <-chan *blocks.Block
 
Constants ¶
This section is empty.
Variables ¶
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 ¶
func New(bs blockstore.Blockstore, rem exchange.Interface) (*BlockService, error)
NewBlockService creates a BlockService with given datastore instance.
func (*BlockService) AddBlock ¶
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