Documentation ¶
Index ¶
- type BlockUploaded
- type PeerWriter
- func (p *PeerWriter) CancelRequest(msg peerprotocol.CancelMessage)
- func (p *PeerWriter) Done() chan struct{}
- func (p *PeerWriter) Messages() <-chan interface{}
- func (p *PeerWriter) Run()
- func (p *PeerWriter) SendMessage(msg peerprotocol.Message)
- func (p *PeerWriter) SendPiece(msg peerprotocol.RequestMessage, pi io.ReaderAt)
- func (p *PeerWriter) Stop()
- type Piece
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockUploaded ¶
type BlockUploaded struct {
Length uint32
}
BlockUploaded is used to signal the Torrent when a piece block is uploaded to remote peer. BlockUploaded can be used to count the number of bytes uploaded to peers.
type PeerWriter ¶
type PeerWriter struct {
// contains filtered or unexported fields
}
PeerWriter is responsible for writing BitTorrent protocol messages to the peer connection.
func New ¶
func New(conn net.Conn, l logger.Logger, maxQueuedRequests int, fastEnabled bool, b *ratelimit.Bucket) *PeerWriter
New returns a new PeerWriter by wrapping a net.Conn.
func (*PeerWriter) CancelRequest ¶
func (p *PeerWriter) CancelRequest(msg peerprotocol.CancelMessage)
CancelRequest cancels the previously received "request" message.
func (*PeerWriter) Done ¶
func (p *PeerWriter) Done() chan struct{}
Done returns a channel that is closed when run loop exists.
func (*PeerWriter) Messages ¶
func (p *PeerWriter) Messages() <-chan interface{}
Messages returns a channel. Various events from the writer are sent to this channel.
func (*PeerWriter) SendMessage ¶
func (p *PeerWriter) SendMessage(msg peerprotocol.Message)
SendMessage is used to send a protocol message to the Peer.
func (*PeerWriter) SendPiece ¶
func (p *PeerWriter) SendPiece(msg peerprotocol.RequestMessage, pi io.ReaderAt)
SendPiece is used to send a "piece" message to the Peer. Data is not read when the method is called. Data is read by the run loop when writing the piece message.
type Piece ¶
type Piece struct { Data io.ReaderAt peerprotocol.RequestMessage }
Piece of the torrent. Data is read by the PeerWriter's Run loop.
func (Piece) ID ¶
func (p Piece) ID() peerprotocol.MessageID
ID returns the BitTorrent protocol message ID.