Class RubyTorrent::Piece
In: lib/rubytorrent/package.rb
Parent: Object

a Piece is the basic unit of the .torrent metainfo file (though not of the bittorrent protocol). Pieces store their data directly on disk, so many operations here will be slow. each Piece stores data in one or more file pointers.

unlike Blocks and Packages, which are either complete or incomplete, a Piece can be complete but not valid, if the SHA1 check fails. thus, a call to piece.complete? is not sufficient to determine whether the data is ok to use or not.

Pieces handle all the trickiness involved with Blocks: taking in Blocks from arbitrary locations, writing them out to the correct set of file pointers, keeping track of which sections of the data have been filled, claimed but not filled, etc.

Methods

Included Modules

EventSource

Attributes

index  [R] 
length  [R] 
start  [R] 

Public Class methods

Public Instance methods

we don‘t do any checking that this block has been claimed or not.

for a complete Piece, returns a complete Block of specified size and location.

[Validate]