2020-06-02 17:41:59 +10:00
|
|
|
package torrent
|
|
|
|
|
|
|
|
import (
|
2021-11-12 12:37:40 +11:00
|
|
|
"github.com/RoaringBitmap/roaring"
|
2022-11-15 23:22:10 +11:00
|
|
|
|
2020-06-02 17:41:59 +10:00
|
|
|
"github.com/anacrolix/torrent/metainfo"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Contains implementation details that differ between peer types, like Webseeds and regular
|
|
|
|
// BitTorrent protocol connections. Some methods are underlined so as to avoid collisions with
|
|
|
|
// legacy PeerConn methods.
|
|
|
|
type peerImpl interface {
|
2021-10-21 10:28:57 +11:00
|
|
|
// Trigger the actual request state to get updated
|
|
|
|
handleUpdateRequests()
|
2020-06-02 17:41:59 +10:00
|
|
|
writeInterested(interested bool) bool
|
2021-05-09 23:38:38 +10:00
|
|
|
|
2021-12-12 00:04:06 +11:00
|
|
|
// _cancel initiates cancellation of a request and returns acked if it expects the cancel to be
|
|
|
|
// handled by a follow-up event.
|
|
|
|
_cancel(RequestIndex) (acked bool)
|
2021-05-20 20:23:45 +10:00
|
|
|
_request(Request) bool
|
2020-06-02 17:41:59 +10:00
|
|
|
connectionFlags() string
|
2021-01-04 15:51:23 +11:00
|
|
|
onClose()
|
2020-06-02 17:41:59 +10:00
|
|
|
onGotInfo(*metainfo.Info)
|
2022-03-11 13:33:34 +11:00
|
|
|
// Drop connection. This may be a no-op if there is no connection.
|
2020-06-02 17:41:59 +10:00
|
|
|
drop()
|
2022-03-11 13:33:34 +11:00
|
|
|
// Rebuke the peer
|
|
|
|
ban()
|
2020-06-04 11:50:20 +10:00
|
|
|
String() string
|
2022-12-31 11:27:47 +11:00
|
|
|
peerImplStatusLines() []string
|
2021-11-12 12:37:40 +11:00
|
|
|
|
|
|
|
// All if the peer should have everything, known if we know that for a fact. For example, we can
|
|
|
|
// guess at how many pieces are in a torrent, and assume they have all pieces based on them
|
|
|
|
// having sent haves for everything, but we don't know for sure. But if they send a have-all
|
|
|
|
// message, then it's clear that they do.
|
|
|
|
peerHasAllPieces() (all, known bool)
|
|
|
|
peerPieces() *roaring.Bitmap
|
2020-06-02 17:41:59 +10:00
|
|
|
}
|