request_strategy

package
v1.33.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MPL-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRequestablePieces added in v1.32.0

func GetRequestablePieces(input Input, f func(t *Torrent, p *Piece, pieceIndex int))

Calls f with requestable pieces in order.

func Run

func Run(input Input) map[PeerId]PeerNextRequestState

TODO: We could do metainfo requests here.

Types

type ChunkIndex added in v1.32.0

type ChunkIndex = uint32

type ChunkSpec

type ChunkSpec = types.ChunkSpec

This can be made into a type-param later, will be great for testing.

type ChunksIter

type ChunksIter interface {
	Iter(func(ChunkIndex))
}

type ChunksIterFunc added in v1.33.0

type ChunksIterFunc func(func(ChunkIndex))

type ClientPieceOrder

type ClientPieceOrder struct{}

type Input

type Input struct {
	Torrents           []Torrent
	MaxUnverifiedBytes int64
}

type Peer

type Peer struct {
	Pieces           roaring.Bitmap
	MaxRequests      int
	ExistingRequests roaring.Bitmap
	Choking          bool
	PieceAllowedFast roaring.Bitmap
	DownloadRate     float64
	Age              time.Duration
	// This is passed back out at the end, so must support equality. Could be a type-param later.
	Id PeerId
}

func (*Peer) HasPiece

func (p *Peer) HasPiece(i pieceIndex) bool

type PeerId

type PeerId interface {
	Uintptr() uintptr
}

type PeerNextRequestState

type PeerNextRequestState struct {
	Interested bool
	Requests   roaring.Bitmap
}

type Piece

type Piece struct {
	Request           bool
	Priority          piecePriority
	Partial           bool
	Availability      int64
	Length            int64
	NumPendingChunks  int
	IterPendingChunks ChunksIter
}

type Request

type Request = types.Request

type RequestIndex added in v1.32.0

type RequestIndex = uint32

type Torrent

type Torrent struct {
	Pieces   []Piece
	Capacity storage.TorrentCapacity
	// Unclosed Peers. Not necessary for getting requestable piece ordering.
	Peers []Peer
	// Some value that's unique and stable between runs. Could even use the infohash?
	InfoHash       metainfo.Hash
	ChunksPerPiece int

	MaxUnverifiedBytes int64
}

Jump to

Keyboard shortcuts

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