peerreader

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxBlockSize allowed in "request" messages.
	MaxBlockSize = 16 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerReader

type PeerReader struct {
	// contains filtered or unexported fields
}

PeerReader is used for reading and parsing messages from a net.Conn.

func New

func New(s network.Stream, l logger.Logger, pieceTimeout time.Duration, b *ratelimit.Bucket) *PeerReader

New returns a new PeerReader by wrapping a net.Conn.

func (*PeerReader) Done

func (p *PeerReader) Done() chan struct{}

Done returns a channel that is closed when the read loop exists.

func (*PeerReader) Messages

func (p *PeerReader) Messages() <-chan interface{}

Messages returns a channel. All messages read by this PeerReader is sent to this channel.

func (*PeerReader) Run

func (p *PeerReader) Run()

Run the read loop.

func (*PeerReader) Stop

func (p *PeerReader) Stop()

Stop the read loop.

type Piece

type Piece struct {
	peerprotocol.PieceMessage
	Buffer bufferpool.Buffer
}

Piece message that is read from peers. Data of the piece is wrapped with a bufferpool.Buffer object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL