request_strategy

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MPL-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(input Input) map[PeerId]PeerNextRequestState

TODO: We could do metainfo requests here.

Types

type ChunkSpec

type ChunkSpec = types.ChunkSpec

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

type ChunksIter

type ChunksIter func(func(types.ChunkSpec))

type ClientPieceOrder

type ClientPieceOrder struct{}

type Input

type Input struct {
	Torrents           []Torrent
	MaxUnverifiedBytes int64
}

type Peer

type Peer struct {
	HasPiece           func(i pieceIndex) bool
	MaxRequests        int
	HasExistingRequest func(r Request) bool
	Choking            bool
	PieceAllowedFast   func(pieceIndex) bool
	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
}

type PeerId

type PeerId interface {
	Uintptr() uintptr
}

type PeerNextRequestState

type PeerNextRequestState struct {
	Interested bool
	Requests   map[Request]struct{}
}

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 Torrent

type Torrent struct {
	Pieces   []Piece
	Capacity *func() *int64
	Peers    []Peer // not closed.
	// Some value that's unique and stable between runs. Could even use the infohash?
	StableId uintptr

	MaxUnverifiedBytes int64
}

Jump to

Keyboard shortcuts

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