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