p2p

package
v0.0.0-...-6621f61 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRequestBlockSize = 2 << 13
View Source
const MaxUnfulfilledRequestBacklog = 5

Variables

This section is empty.

Functions

func AttemptDownloadPiece

func AttemptDownloadPiece(c *client.Client, pw *pieceWork) ([]byte, error)

func CheckIntegrity

func CheckIntegrity(pw *pieceWork, buffer []byte) error

检查完整性,即 check sum

Types

type Torrent

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

func (*Torrent) CalculatePieceBounds

func (t *Torrent) CalculatePieceBounds(index int) (begin int, end int)

func (*Torrent) CalculatePieceSize

func (t *Torrent) CalculatePieceSize(index int) int

func (*Torrent) Download

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

下载整个 file ,数据存储在内存中

func (*Torrent) StartDownloadWorker

func (t *Torrent) StartDownloadWorker(
	peer peers.Peer,
	workQueue chan *pieceWork,
	results chan *pieceResult,
)

Jump to

Keyboard shortcuts

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