Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewManager ¶
func NewManager(info torrent.Info, pieceRepo Repository) *manager
NewManager creates new piece manager
Types ¶
type Manager ¶
type Manager interface {
//SetPeerPieces associates remote peer and pieces it possess
SetPeerPieces(peerID string, pieces []bool)
//PieceSize returns size of a piece corresponding to given index,
//often last piece has different size than preceding pieces.
PieceSize(index uint32) uint32
ChunkSize() uint32
//Get retrieves piece corresponding to given index
Get(index uint32) (pieceData []byte, err error)
//PieceDone saves piece in the storage
PieceDone(index uint32, pieceData []byte) error
//NextPiece checks if peers has more pieces to offer.
// (false, 0) -> peer has no more pieces
// (true, index) -> index is the next piece index to request
NextPiece(peerID string) (hasNext bool, index uint32)
//IsLastChunk checks if the whole piece was downloaded
IsLastChunk(pieceIndex, offset uint32) bool
}
Manager manages file pieces, in bittorent protocol file is divided into pieces. Torrent file contains information about piece size and piece hash. Implementation of this interface must be thread safe.
Click to show internal directories.
Click to hide internal directories.