1 package request_strategy
7 type PeerNextRequestState struct {
9 Requests map[Request]struct{}
12 type PeerId interface {
17 HasPiece func(i pieceIndex) bool
19 HasExistingRequest func(r Request) bool
21 PieceAllowedFast func(pieceIndex) bool
24 // This is passed back out at the end, so must support equality. Could be a type-param later.
28 func (p *Peer) pieceAllowedFastOrDefault(i pieceIndex) bool {
29 if f := p.PieceAllowedFast; f != nil {
35 // TODO: This might be used in more places I think.
36 func (p *Peer) canRequestPiece(i pieceIndex) bool {
37 return p.HasPiece(i) && (!p.Choking || (p.PieceAllowedFast != nil && p.PieceAllowedFast(i)))