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