1 package request_strategy
6 "github.com/RoaringBitmap/roaring"
9 type PeerNextRequestState struct {
11 Requests roaring.Bitmap
14 type PeerId interface {
21 ExistingRequests roaring.Bitmap
23 PieceAllowedFast roaring.Bitmap
26 // This is passed back out at the end, so must support equality. Could be a type-param later.
30 // TODO: This might be used in more places I think.
31 func (p *Peer) canRequestPiece(i pieceIndex) bool {
32 return (!p.Choking || p.PieceAllowedFast.Contains(uint32(i))) && p.HasPiece(i)
35 func (p *Peer) HasPiece(i pieceIndex) bool {
36 return p.Pieces.Contains(uint32(i))