piecepicker

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PiecePicker

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

PiecePicker runs an algorithm to determine which piece to download next, from which peer or webseed source. PiecePicker keeps track availability of pieces among peers.

func New

func New(pieces []piece.Piece, maxDuplicateDownload int, webseedSources []*webseedsource.WebseedSource) *PiecePicker

New returns a new PiecePicker.

func (*PiecePicker) Available

func (p *PiecePicker) Available() uint32

Available returns the number of available pieces among the swarm.

func (*PiecePicker) CloseWebseedDownloader added in v1.8.10

func (p *PiecePicker) CloseWebseedDownloader(src *webseedsource.WebseedSource)

CloseWebseedDownloader closes the download from a webseed source.

func (*PiecePicker) HandleAllowedFast

func (p *PiecePicker) HandleAllowedFast(pe *peer.Peer, i uint32)

HandleAllowedFast must be called to set the allowed-fast status of the piece at peer.

func (*PiecePicker) HandleCancelDownload

func (p *PiecePicker) HandleCancelDownload(pe *peer.Peer, i uint32)

HandleCancelDownload must be called to update indexes when a piece download is canceled from the peer.

func (*PiecePicker) HandleChoke added in v0.3.0

func (p *PiecePicker) HandleChoke(pe *peer.Peer, i uint32)

HandleChoke must be called to set choke status of the remote peer.

func (*PiecePicker) HandleDisconnect

func (p *PiecePicker) HandleDisconnect(pe *peer.Peer)

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

func (*PiecePicker) HandleHave

func (p *PiecePicker) HandleHave(pe *peer.Peer, i uint32)

HandleHave must be called to set the availability of the piece at the peer.

func (*PiecePicker) HandleSnubbed

func (p *PiecePicker) HandleSnubbed(pe *peer.Peer, i uint32)

HandleSnubbed must be called to set the peer as snubbed when it is slow or stalled.

func (*PiecePicker) HandleUnchoke added in v0.3.0

func (p *PiecePicker) HandleUnchoke(pe *peer.Peer, i uint32)

HandleUnchoke must be called to unset choke status of the remote peer.

func (*PiecePicker) PickFor added in v0.3.0

func (p *PiecePicker) PickFor(pe *peer.Peer) (pp *piece.Piece, allowedFast bool)

PickFor selects the next piece for download from the peer.

func (*PiecePicker) PickWebseed added in v1.8.10

PickWebseed returns the next spec for downloading files from webseed sources.

func (*PiecePicker) RequestedPeers

func (p *PiecePicker) RequestedPeers(i uint32) []*peer.Peer

RequestedPeers returns the number of peers that the piece with the index is requested from.

func (*PiecePicker) RequestedWebseedSource added in v1.8.10

func (p *PiecePicker) RequestedWebseedSource(i uint32) *webseedsource.WebseedSource

RequestedWebseedSource returns the number of webseed sources that the piece with the index is requested from.

func (*PiecePicker) WebseedStopAt added in v1.8.10

func (p *PiecePicker) WebseedStopAt(src *webseedsource.WebseedSource, i uint32) (closed bool)

WebseedStopAt sets the webseed downloader to stop at index `i`.

type Range added in v1.8.10

type Range struct {
	Begin, End uint32
}

Range is a piece index range. Begin is inclusive, End is exclusive.

func (Range) Len added in v1.8.10

func (r Range) Len() uint32

Len returns the number of pieces in the range.

type WebseedDownloadSpec added in v1.8.10

type WebseedDownloadSpec struct {
	Source *webseedsource.WebseedSource
	Begin  uint32 // piece index
	End    uint32 // piece index
}

WebseedDownloadSpec contains information for downloading torrent data from webseed sources.

Jump to

Keyboard shortcuts

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