peer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	*Peer
	Message interface{}
}

type Peer

type Peer struct {
	*peerconn.Conn

	AmChoking      bool
	AmInterested   bool
	PeerChoking    bool
	PeerInterested bool

	OptimisticUnchoked bool

	// Snubbed means peer is sending pieces too slow.
	Snubbed bool

	Downloading bool

	BytesDownlaodedInChokePeriod int64
	BytesUploadedInChokePeriod   int64

	// Messages received while we don't have info yet are saved here.
	Messages []interface{}

	ExtensionHandshake *peerprotocol.ExtensionHandshakeMessage

	PEX *pex
	// contains filtered or unexported fields
}

func New

func New(p *peerconn.Conn, snubTimeout time.Duration) *Peer

func (*Peer) Close

func (p *Peer) Close()

func (*Peer) ResetSnubTimer

func (p *Peer) ResetSnubTimer()

func (*Peer) Run

func (p *Peer) Run(messages chan Message, pieces chan PieceMessage, snubbed, disconnect chan *Peer)

func (*Peer) StartPEX

func (p *Peer) StartPEX(initialPeers map[*Peer]struct{})

func (*Peer) StopSnubTimer

func (p *Peer) StopSnubTimer()

type PieceMessage

type PieceMessage struct {
	*Peer
	Piece peerreader.Piece
}

Jump to

Keyboard shortcuts

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