]> Sergey Matveev's repositories - btrtrc.git/blob - peer-impl.go
Drop support for go 1.20
[btrtrc.git] / peer-impl.go
1 package torrent
2
3 import (
4         "github.com/RoaringBitmap/roaring"
5
6         "github.com/anacrolix/torrent/metainfo"
7 )
8
9 // Contains implementation details that differ between peer types, like Webseeds and regular
10 // BitTorrent protocol connections. Some methods are underlined so as to avoid collisions with
11 // legacy PeerConn methods.
12 type peerImpl interface {
13         // Trigger the actual request state to get updated
14         handleUpdateRequests()
15         writeInterested(interested bool) bool
16
17         // _cancel initiates cancellation of a request and returns acked if it expects the cancel to be
18         // handled by a follow-up event.
19         _cancel(RequestIndex) (acked bool)
20         _request(Request) bool
21         connectionFlags() string
22         onClose()
23         onGotInfo(*metainfo.Info)
24         // Drop connection. This may be a no-op if there is no connection.
25         drop()
26         // Rebuke the peer
27         ban()
28         String() string
29         peerImplStatusLines() []string
30
31         // All if the peer should have everything, known if we know that for a fact. For example, we can
32         // guess at how many pieces are in a torrent, and assume they have all pieces based on them
33         // having sent haves for everything, but we don't know for sure. But if they send a have-all
34         // message, then it's clear that they do.
35         peerHasAllPieces() (all, known bool)
36         peerPieces() *roaring.Bitmap
37 }