github.com/anacrolix/torrent@v1.61.0/internal/request-strategy/peer.go (about) 1 package requestStrategy 2 3 import ( 4 "iter" 5 6 typedRoaring "github.com/anacrolix/torrent/typed-roaring" 7 ) 8 9 type PeerRequestState struct { 10 Interested bool 11 Requests PeerRequests 12 // Cancelled and waiting response 13 Cancelled typedRoaring.Bitmap[RequestIndex] 14 } 15 16 // A set of request indices iterable by order added. 17 type PeerRequests interface { 18 // Can be more efficient than GetCardinality. 19 IsEmpty() bool 20 // See roaring.Bitmap.GetCardinality. 21 GetCardinality() uint64 22 Contains(RequestIndex) bool 23 // Should not adjust iteration order if item already exists, although I don't think that usage 24 // exists. 25 Add(RequestIndex) 26 // See roaring.Bitmap.Rank. 27 Rank(RequestIndex) uint64 28 // Must yield in order items were added. 29 Iterate(func(RequestIndex) bool) (all bool) 30 // Must yield in order items were added. 31 Iterator() iter.Seq[RequestIndex] 32 // See roaring.Bitmap.CheckedRemove. 33 CheckedRemove(RequestIndex) bool 34 // Iterate a snapshot of the values. It is safe to mutate the underlying data structure. 35 IterateSnapshot(func(RequestIndex) bool) 36 }