]> Sergey Matveev's repositories - btrtrc.git/blob - peer-impl.go
Don't use non-directory webseed URLs for multi-file torrents
[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         // Whether the outstanding local request cardinality is low enough to warrant an update.
15         isLowOnRequests() bool
16         writeInterested(interested bool) bool
17
18         // Neither of these return buffer room anymore, because they're currently both posted. There's
19         // also PeerConn.writeBufferFull for when/where it matters.
20         _cancel(RequestIndex) bool
21         _request(Request) bool
22
23         connectionFlags() string
24         onClose()
25         onGotInfo(*metainfo.Info)
26         drop()
27         String() string
28         connStatusString() string
29
30         // All if the peer should have everything, known if we know that for a fact. For example, we can
31         // guess at how many pieces are in a torrent, and assume they have all pieces based on them
32         // having sent haves for everything, but we don't know for sure. But if they send a have-all
33         // message, then it's clear that they do.
34         peerHasAllPieces() (all, known bool)
35         peerPieces() *roaring.Bitmap
36 }