Documentation ¶
Index ¶
Constants ¶
const Protocol protocol.ID = "/blockstream/1.0.0"
Variables ¶
var ErrNoProviders = errors.New("blockstream: no providers")
Functions ¶
Types ¶
type BlockStream ¶
type BlockStream struct { Host host.Host Granter access.Granter Blocks blockstore.Blockstore // contains filtered or unexported fields }
func NewBlockStream ¶
func NewBlockStream(ctx context.Context, host host.Host, bstore blockstore.Blockstore, granter access.Granter, opts ...Option) *BlockStream
func (*BlockStream) Close ¶
func (bs *BlockStream) Close() error
func (*BlockStream) Session ¶
func (bs *BlockStream) Session(ctx context.Context, peers []peer.ID, opts ...SessionOption) (*Session, error)
Session starts new BlockStream session between current node and providing 'peers'.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
TODO Refactor this, my ayes hurt watching this
func (*Session) Blocks ¶
Blocks fetches Blocks by their CIDs evenly from the remote providers in the session. Block order is guaranteed to be the same as requested.
func (*Session) Stream ¶
func (ses *Session) Stream(ctx context.Context, in <-chan []cid.Cid) (<-chan block.Result, <-chan error)
Stream starts direct Block fetching from remote providers. It fetches the Blocks requested with 'in' chan by their ids. Stream is automatically stopped when both: the requested blocks are all fetched and 'in' chan is closed. It might be also terminated with the provided context. Block order is guaranteed to be the same as requested through the `in` chan.
type SessionOption ¶ added in v1.2.0
type SessionOption func(*sessionOpts)
func Blockstore ¶ added in v1.2.0
func Blockstore(bs blockstore.Blockstore) SessionOption
func Offline ¶ added in v1.2.0
func Offline(off bool) SessionOption
func Save ¶ added in v1.2.0
func Save(s bool) SessionOption
type Streamer ¶ added in v1.2.0
type Streamer interface { // Stream initiates ordered stream of Blocks from implementation defined source. Stream(context.Context, <-chan []cid.Cid) (<-chan block.Result, <-chan error) }
TODO Interface is not final TODO Implementation distributing requests between multiple streamers by some abstract characteristic.