Net::BitTorrent::Session::Piece - Single piece


new ( { [ARGS] } )

Creates a Net::BitTorrent::Session::Piece object. This constructor should not be used directly.


as_string ( [ VERBOSE ] )

Returns a 'ready to print' dump of the Net::BitTorrent::Session::Piece object's data structure. If called in void context, the structure is printed to STDERR.

See also: [id://317520], Net::BitTorrent::as_string()

blocks ( )

Returns a hash of key/value pairs for each Net::BitTorrent::Session::Piece::Block object related to this piece. The keys of this hash are offsets.

If this piece is not marked working, undef is the return value.

check ( )

Returns a cached boolean value indicating whether or not this piece passes hash checking. This value is cached to save time; to be sure that this value is accurate, use verify ( ).

client ( )

Returns the Net::BitTorrent object related to this file.

hash ( )

Returns the 20-byte SHA1 hash used to verify the contents of this piece.

See also: verify ( )

index ( )

Returns the zero based index of this piece according to the related Net::BitTorrent::Session object.

priority ( [NEWVAL] )

Mutator to set/get the download priority of this piece.

By default, all pieces begin with a priority of two (2).

See also: Net::BitTorrent::Session::File::priority ( )

session ( )

Returns the Net::BitTorrent::Session object related to this file.

size ( )

Returns the size of the piece represented by this object.

verify ( )

Verifies data integrity of this piece by checking against the SHA1 hash.

See also: check ( ), hash ( )

working ( )

Returns a boolean value indicating whether or not we are actively requesting blocks from this piece.


Sanko Robinson <> -



Copyright 2008 by Sanko Robinson <>

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See or the LICENSE file included with this module.

All POD documentation is covered by the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License (

Neither this module nor the AUTHOR is affiliated with BitTorrent, Inc.