sessionpeermanager

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerProviderFinder

type PeerProviderFinder interface {
	FindProvidersAsync(context.Context, cid.Cid) <-chan peer.ID
}

PeerProviderFinder is an interface for finding providers

type PeerTagger

type PeerTagger interface {
	TagPeer(peer.ID, string, int)
	UntagPeer(p peer.ID, tag string)
}

PeerTagger is an interface for tagging peers with metadata

type SessionPeerManager

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

SessionPeerManager tracks and manages peers for a session, and provides the best ones to the session

func New

func New(ctx context.Context, id uint64, tagger PeerTagger, providerFinder PeerProviderFinder) *SessionPeerManager

New creates a new SessionPeerManager

func (*SessionPeerManager) FindMorePeers

func (spm *SessionPeerManager) FindMorePeers(ctx context.Context, c cid.Cid)

FindMorePeers attempts to find more peers for a session by searching for providers for the given Cid

func (*SessionPeerManager) GetOptimizedPeers

func (spm *SessionPeerManager) GetOptimizedPeers() []bssd.OptimizedPeer

GetOptimizedPeers returns the best peers available for a session, along with a rating for how good they are, in comparison to the best peer.

func (*SessionPeerManager) RecordCancels

func (spm *SessionPeerManager) RecordCancels(ks []cid.Cid)

RecordCancels records the fact that cancellations were sent to peers, so if blocks don't arrive, don't let it affect the peer's timeout

func (*SessionPeerManager) RecordPeerRequests

func (spm *SessionPeerManager) RecordPeerRequests(p []peer.ID, ks []cid.Cid)

RecordPeerRequests records that a given set of peers requested the given cids.

func (*SessionPeerManager) RecordPeerResponse

func (spm *SessionPeerManager) RecordPeerResponse(p peer.ID, ks []cid.Cid)

RecordPeerResponse records that a peer received some blocks, and adds the peer to the list of peers if it wasn't already added

func (*SessionPeerManager) SetTimeoutDuration

func (spm *SessionPeerManager) SetTimeoutDuration(timeoutDuration time.Duration)

SetTimeoutDuration changes the length of time used to timeout recording of requests

Jump to

Keyboard shortcuts

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