piece

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const BlockSize = 16 * 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Index  uint32 // index in piece
	Begin  uint32 // offset in piece
	Length uint32 // always equal to BlockSize except the last block of a piece.
}

Block is part of a Piece that is specified in peerprotocol.Request messages.

type Blocks

type Blocks []Block

func (Blocks) Find

func (a Blocks) Find(begin, length uint32) *Block

type Piece

type Piece struct {
	Index     uint32 // index in torrent
	Length    uint32 // always equal to Info.PieceLength except last piece
	Blocks    Blocks
	Data      filesection.Piece // the place to write downloaded bytes
	Hash      []byte
	Verifying bool
	Writing   bool
	Done      bool
}

Piece of a torrent.

func NewPieces

func NewPieces(info *metainfo.Info, files []storage.File) []Piece

func (*Piece) VerifyHash

func (p *Piece) VerifyHash(buf []byte, h hash.Hash) bool

Jump to

Keyboard shortcuts

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