torrent/peer-impl.go

38 lines
1.2 KiB
Go
Raw Normal View History

2020-06-02 07:41:59 +00:00
package torrent
import (
"github.com/RoaringBitmap/roaring"
2022-11-15 12:22:10 +00:00
2020-06-02 07:41:59 +00: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-20 23:28:57 +00:00
// Trigger the actual request state to get updated
handleUpdateRequests()
2020-06-02 07:41:59 +00:00
writeInterested(interested bool) bool
2021-05-09 13:38:38 +00: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)
_request(Request) bool
2020-06-02 07:41:59 +00:00
connectionFlags() string
2021-01-04 04:51:23 +00:00
onClose()
2020-06-02 07:41:59 +00:00
onGotInfo(*metainfo.Info)
2022-03-11 02:33:34 +00:00
// Drop connection. This may be a no-op if there is no connection.
2020-06-02 07:41:59 +00:00
drop()
2022-03-11 02:33:34 +00:00
// Rebuke the peer
ban()
String() string
connStatusString() string
// 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 07:41:59 +00:00
}