AnyEvent-BitTorrent
view release on metacpan or search on metacpan
lib/AnyEvent/BitTorrent.pm view on Meta::CPAN
=item C<on_hash_pass>
This is a subroutine called whenever a piece passes its
L<hashcheck|/"hashcheck( [...] )">. The callback is handed the piece's index.
=item C<state>
This must be one of the following:
=over
=item C<started>
This is the default. The client will attempt to create new connections, make
and fill requests, etc. This is normal client behavior.
=item C<paused>
In this state, connections will be made and accepted but no piece requests
will be made or filled. To resume full, normal behavior, you must call
L<C<start( )>|/"start( )">.
=item C<stopped>
Everything is put on hold. No new outgoing connections are attempted and
incoming connections are rejected. To resume full, normal behavior, you must
call L<C<start( )>|/"start( )">.
=back
=item C<piece_cache>
This is the index list returned by L<C<piece_cache( )>|/"piece_cache( )"> in a
previous instance. Using this should make a complete resume system a trivial
task.
=back
=head2 C<hashcheck( [...] )>
This method expects...
=over
=item ...a list of integers. You could use this to check a range of pieces (a
single file, for example).
$client->hashcheck( 1 .. 5, 34 .. 56 );
=item ...a single integer. Only that specific piece is checked.
$client->hashcheck( 17 );
=item ...nothing. All data related to this torrent will be checked.
$client->hashcheck( );
=back
As pieces pass or fail, your C<on_hash_pass> and C<on_hash_fail> callbacks are
triggered.
=head2 C<start( )>
Sends a 'started' event to trackers and starts performing as a client is
expected. New connections are made and accepted, requests are made and filled,
etc.
=head2 C<stop( )>
Sends a stopped event to trackers, closes all connections, stops attempting
new outgoing connections, rejects incoming connections and closes all open
files.
=head2 C<pause( )>
The client remains mostly active; new connections will be made and accepted,
etc. but no requests will be made or filled while the client is paused.
=head2 C<infohash( )>
Returns the 20-byte SHA1 hash of the value of the info key from the metadata
file.
=head2 C<peerid( )>
Returns the 20 byte string used to identify the client. Please see the
L<spec|/"PeerID Specification"> below.
=head2 C<port( )>
Returns the port number the client is listening on.
=head2 C<size( )>
Returns the total size of all L<files|/"files( )"> described in the torrent's
metadata.
=head2 C<name( )>
Returns the UTF-8 encoded string the metadata suggests we save the file (or
directory, in the case of multi-file torrents) under.
=head2 C<uploaded( )>
Returns the total amount uploaded to remote peers.
=head2 C<downloaded( )>
Returns the total amount downloaded from other peers.
=head2 C<left( )>
Returns the approximate amount based on the pieces we still
L<want|/"wanted( )"> multiplied by the L<size of pieces|/"piece_length( )">.
=head2 C<piece_length( )>
Returns the number of bytes in each piece the file or files are split into.
For the purposes of transfer, files are split into fixed-size pieces which are
( run in 1.282 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )