blockservice

package module
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 13 Imported by: 248

README

go-blockservice

go-blockservice provides a seamless interface to both local and remote storage backends.

Coverage Status Build Status

❗ This repo is no longer maintained.

👉 We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/blockservice. 🏎️ Good news! There is tooling and documentation to expedite a switch in your repo.

⚠️ If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

📚 Learn more, including how to take the maintainership mantle or ask questions, here.

Table of Contents

TODO

The interfaces here really would like to be merged with the blockstore interfaces. The 'dagservice' constructor currently takes a blockservice, but it would be really nice if it could just take a blockstore, and have this package implement a blockstore.

License

MIT © Juan Batiz-Benet

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

This section is empty.

Functions

This section is empty.

Types

type BlockGetter deprecated

type BlockGetter interface {
	// GetBlock gets the requested block.
	GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error)

	// GetBlocks does a batch request for the given cids, returning blocks as
	// they are found, in no particular order.
	//
	// It may not be able to find all requested blocks (or the context may
	// be canceled). In that case, it will close the channel early. It is up
	// to the consumer to detect this situation and keep track which blocks
	// it has received and which it hasn't.
	GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blocks.Block
}

BlockGetter is the common interface shared between blockservice sessions and the blockservice.

Deprecated: use github.com/ipfs/boxo/blockservice.BlockGetter

type BlockService deprecated

type BlockService interface {
	io.Closer
	BlockGetter

	// Blockstore returns a reference to the underlying blockstore
	Blockstore() blockstore.Blockstore

	// Exchange returns a reference to the underlying exchange (usually bitswap)
	Exchange() exchange.Interface

	// AddBlock puts a given block to the underlying datastore
	AddBlock(ctx context.Context, o blocks.Block) error

	// AddBlocks adds a slice of blocks at the same time using batching
	// capabilities of the underlying datastore whenever possible.
	AddBlocks(ctx context.Context, bs []blocks.Block) error

	// DeleteBlock deletes the given block from the blockservice.
	DeleteBlock(ctx context.Context, o cid.Cid) error
}

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.

Deprecated: use github.com/ipfs/boxo/blockservice.BlockService

func New deprecated

NewBlockService creates a BlockService with given datastore instance.

Deprecated: use github.com/ipfs/boxo/blockservice.New

func NewWriteThrough deprecated

func NewWriteThrough(bs blockstore.Blockstore, rem exchange.Interface) BlockService

NewWriteThrough creates a BlockService that guarantees writes will go through to the blockstore and are not skipped by cache checks.

Deprecated: use github.com/ipfs/boxo/blockservice.NewWriteThrough

type Session deprecated

type Session struct {
	// contains filtered or unexported fields
}

Session is a helper type to provide higher level access to bitswap sessions

Deprecated: use github.com/ipfs/boxo/blockservice.Session

func NewSession deprecated

func NewSession(ctx context.Context, bs BlockService) *Session

NewSession creates a new session that allows for controlled exchange of wantlists to decrease the bandwidth overhead. If the current exchange is a SessionExchange, a new exchange session will be created. Otherwise, the current exchange will be used directly.

Deprecated: use github.com/ipfs/boxo/blockservice.NewSession

func (*Session) GetBlock

func (s *Session) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error)

GetBlock gets a block in the context of a request session

func (*Session) GetBlocks

func (s *Session) GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blocks.Block

GetBlocks gets blocks in the context of a request session

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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