peer-impl.go 1.2 KB

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