p2p

package
v0.0.0-...-571b077 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

type Peer struct {
	PeerID   [20]byte
	IP       *net.TCPAddr
	Conn     *net.TCPConn
	BitField msg.Bitfield
	Start    time.Time

	Active bool

	Rates *Rates

	Downloading bool        // Should upload to best 4 peers.
	BlockOut    chan []byte // Channel for sending blocks.

	Choked       bool
	Interested   bool
	IsChoking    bool
	IsInterested bool
	// UI elements.
	Activity *tview.TextView
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(address *net.TCPAddr, bitfieldLength int) *Peer

func (*Peer) Run

func (p *Peer) Run(
	ID [20]byte,
	t *torrent.Torrent,
	workQ chan torrent.Piece,
	dataQ chan<- *torrent.PieceData,
	requestQ chan<- Request,
)

type Rates

type Rates struct {
	Downloaded int
	Uploaded   int

	LastDownloaded int
	LastUploaded   int
}

type Request

type Request struct {
	Peer   *Peer
	Idx    int
	Offset int
	Length int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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