session

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerManager

type PeerManager interface {
	FindMorePeers(context.Context, cid.Cid)
	GetOptimizedPeers() []bssd.OptimizedPeer
	RecordPeerRequests([]peer.ID, []cid.Cid)
	RecordPeerResponse(peer.ID, []cid.Cid)
	RecordCancels([]cid.Cid)
}

PeerManager provides an interface for tracking and optimize peers, and requesting more when neccesary.

type RequestSplitter

type RequestSplitter interface {
	SplitRequest([]bssd.OptimizedPeer, []cid.Cid) []bssd.PartialRequest
	RecordDuplicateBlock()
	RecordUniqueBlock()
}

RequestSplitter provides an interface for splitting a request for Cids up among peers.

type Session

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

Session holds state for an individual bitswap transfer operation. This allows bitswap to make smarter decisions about who to send wantlist info to, and who to request blocks from.

func New

func New(ctx context.Context,
	id uint64,
	wm WantManager,
	pm PeerManager,
	srs RequestSplitter,
	notif notifications.PubSub,
	initialSearchDelay time.Duration,
	periodicSearchDelay delay.D) *Session

New creates a new bitswap session whose lifetime is bounded by the given context.

func (*Session) GetAverageLatency

func (s *Session) GetAverageLatency() time.Duration

GetAverageLatency returns the average latency for block requests.

func (*Session) GetBlock

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

GetBlock fetches a single block.

func (*Session) GetBlocks

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

GetBlocks fetches a set of blocks within the context of this session and returns a channel that found blocks will be returned on. No order is guaranteed on the returned blocks.

func (*Session) IsWanted

func (s *Session) IsWanted(c cid.Cid) bool

IsWanted returns true if this session is waiting to receive the given Cid.

func (*Session) ReceiveFrom

func (s *Session) ReceiveFrom(from peer.ID, ks []cid.Cid)

ReceiveFrom receives incoming blocks from the given peer.

func (*Session) SetBaseTickDelay

func (s *Session) SetBaseTickDelay(baseTickDelay time.Duration)

SetBaseTickDelay changes the rate at which ticks happen.

type WantManager

type WantManager interface {
	WantBlocks(ctx context.Context, ks []cid.Cid, peers []peer.ID, ses uint64)
	CancelWants(ctx context.Context, ks []cid.Cid, peers []peer.ID, ses uint64)
}

WantManager is an interface that can be used to request blocks from given peers.

Jump to

Keyboard shortcuts

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