AnyEvent-BitTorrent

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


This method expects...

- ...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 );

- ...a single integer. Only that specific piece is checked.

            $client->hashcheck( 17 );

- ...nothing. All data related to this torrent will be checked.

            $client->hashcheck( );

As pieces pass or fail, your `on_hash_pass` and `on_hash_fail` callbacks are
triggered.

## `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.

## `stop( )`

Sends a stopped event to trackers, closes all connections, stops attempting
new outgoing connections, rejects incoming connections and closes all open
files.

## `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.

## `infohash( )`

Returns the 20-byte SHA1 hash of the value of the info key from the metadata
file.

## `peerid( )`

Returns the 20 byte string used to identify the client. Please see the
[spec](#peerid-specification) below.

## `port( )`

Returns the port number the client is listening on.

## `size( )`

Returns the total size of all [files](#files) described in the torrent's
metadata.

## `name( )`

Returns the UTF-8 encoded string the metadata suggests we save the file (or
directory, in the case of multi-file torrents) under.

## `uploaded( )`

Returns the total amount uploaded to remote peers.

## `downloaded( )`

Returns the total amount downloaded from other peers.

## `left( )`

Returns the approximate amount based on the pieces we still
[want](#wanted) multiplied by the [size of pieces](#piece_length).

## `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
all the same length except for possibly the last one which may be truncated.

## `bitfield( )`

Returns a packed binary string in ascending order (ready for `vec()`). Each
index that the client has is set to one and the rest are set to zero.

## `wanted( )`

Returns a packed binary string in ascending order (ready for `vec()`). Each
index that the client has or simply does not want is set to zero and the rest
are set to one.

This value is calculated every time the method is called. Keep that in mind.

## `complete( )`

Returns true if we have downloaded everything we [wanted](#wanted) which
is not to say that we have all data and can [seed](#seed).

## `seed( )`

Returns true if we have all data related to the torrent.

## `files( )`

Returns a list of hash references with the following keys:

- `length`

    Which is the size of file in bytes.

- `path`

    Which is the absolute path of the file.

- `priority`

    Download priority for this file. By default, all files have a priority of
    `1`. There is no built in scale; the higher the priority, the better odds a
    piece from it will be downloaded first. Setting a file's priority to `1000`
    while the rest are still at `1` will likely force the file to complete before
    any other file is started.

    We do not download files with a priority of zero.



( run in 0.509 second using v1.01-cache-2.11-cpan-b16cb0d3907 )