peer

package
v0.0.0-...-2f17533 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBacklog = 5

MaxBacklog is the number of unfulfilled requests a client can have in its pipeline

View Source
const MaxBlockSize = 16384

MaxBlockSize is the largest number of bytes a request can ask for

View Source
const MaxInPipeLine = 5

MaxInPipeLine is the maximum number of request that can be kept in queue waiting for them to be picked up by a worker

View Source
const MaxSize = 16384

MaxSize is the maximmum size we get request for from a peer in one request

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

type Peer struct {
	IP   net.IP
	Port uint16
}

Peer struct containg ip and port of the client

func DecodePeer

func DecodePeer(bin []byte) ([]Peer, error)

DecodePeer takes the peers string and converts them into the an array of Peers struct

func (Peer) String

func (p Peer) String() string

String is used to convert the peer struct to a valid ip address

type Torrent

type Torrent struct {
	Peers       []Peer
	PeerID      []byte
	InfoHash    [20]byte
	PieceHashes [][20]byte
	PieceLength int
	Length      int
	Name        string
}

Torrent holds data required to download a torrent from a list of peers

func (*Torrent) Download

func (t *Torrent) Download() ([]byte, error)

Download make a worker queues,launches go routines ,co-ordinates with the result basically this func is the heart of the package which does it all

Jump to

Keyboard shortcuts

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