unchoker

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

type Peer interface {
	// Sends messages and set choking status of local peeer
	Choke()
	Unchoke()

	// Choking returns choke status of local peer
	Choking() bool

	// Interested returns interest status of remote peer
	Interested() bool

	// SetOptimistic sets the uptimistic unchoke status of peer
	SetOptimistic(value bool)
	// OptimisticUnchoked returns the value previously set by SetOptimistic
	Optimistic() bool

	DownloadSpeed() int
	UploadSpeed() int
}

Peer of a torrent.

type Unchoker

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

Unchoker implements an algorithm to select peers to unchoke based on their download speed.

func New

func New(numUnchoked, numOptimisticUnchoked int) *Unchoker

New returns a new Unchoker.

func (*Unchoker) FastUnchoke

func (u *Unchoker) FastUnchoke(pe Peer)

FastUnchoke must be called when remote peer is interested. Remote peer is unchoked immediately if there are not enough unchoked peers. Without this function, remote peer would have to wait for next unchoke period.

func (*Unchoker) HandleDisconnect

func (u *Unchoker) HandleDisconnect(pe Peer)

HandleDisconnect must be called to remove the peer from internal indexes.

func (*Unchoker) TickUnchoke

func (u *Unchoker) TickUnchoke(allPeers []Peer, torrentCompleted bool)

TickUnchoke must be called at every 10 seconds.

Jump to

Keyboard shortcuts

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