libktorrent  2.2.0
Public Slots | Public Member Functions | List of all members
bt::PeerDownloader Class Reference

Class which downloads pieces from a Peer. More...

#include <peerdownloader.h>

Inheritance diagram for bt::PeerDownloader:
Inheritance graph
[legend]

Public Slots

void cancel (const Request &req) override
 
void cancelAll () override
 
void download (const Request &req) override
 
void onRejected (const Request &req)
 
void update ()
 

Public Member Functions

 PeerDownloader (Peer *peer, Uint32 chunk_size)
 
bool canAddRequest () const override
 See if we can add a request to the wait_queue.
 
bool canDownloadChunk () const override
 
void checkTimeouts () override
 
void choked ()
 
Uint32 getDownloadRate () const override
 
Uint32 getMaxChunkDownloads () const
 Get the maximum number of chunk downloads.
 
QString getName () const override
 
Uint32 getNumRequests () const
 Get the number of active requests.
 
const PeergetPeer () const
 Get the Peer.
 
bool hasChunk (Uint32 idx) const override
 
bool isChoked () const override
 Is the Peer choked.
 
bool isNull () const
 Is NULL (is the Peer set)
 
void piece (const Piece &p)
 
- Public Member Functions inherited from bt::PieceDownloader
virtual void cancel (const bt::Request &req)=0
 
virtual void cancelAll ()=0
 
virtual void download (const bt::Request &req)=0
 
int getNumGrabbed () const
 Get the number of times this PeerDownloader was grabbed.
 
int grab ()
 
bool isNearlyDone () const
 See if this PieceDownloader has nearly finished a chunk.
 
void release ()
 
void setNearlyDone (bool nd)
 Set the nearly done status of the PeerDownloader.
 

Additional Inherited Members

- Signals inherited from bt::PieceDownloader
void rejected (const bt::Request &req)
 
void timedout (const bt::Request &r)
 

Detailed Description

Author
Joris Guisson This class downloads Piece's from a Peer.

Definition at line 119 of file peerdownloader.h.

Constructor & Destructor Documentation

◆ PeerDownloader()

bt::PeerDownloader::PeerDownloader ( Peer peer,
Uint32  chunk_size 
)

Constructor, set the Peer

Parameters
peerThe Peer
chunk_sizeSize of a chunk in bytes

Referenced by bt::TimeStampedRequest::operator=().

Member Function Documentation

◆ cancel

void bt::PeerDownloader::cancel ( const Request req)
overrideslot

Cancel a Request.

Parameters
reqThe Request

◆ cancelAll

void bt::PeerDownloader::cancelAll ( )
overrideslot

Cancel all Requests

◆ canDownloadChunk()

bool bt::PeerDownloader::canDownloadChunk ( ) const
overridevirtual

Whether or not we can download another chunk from this.

Implements bt::PieceDownloader.

Referenced by bt::TimeStampedRequest::operator=().

◆ checkTimeouts()

void bt::PeerDownloader::checkTimeouts ( )
overridevirtual

Check for timed out requests.

Implements bt::PieceDownloader.

◆ choked()

void bt::PeerDownloader::choked ( )

The peer has been choked, all pending requests are rejected. (except for allowed fast ones)

◆ download

void bt::PeerDownloader::download ( const Request req)
overrideslot

Send a Request. Note that the DownloadCap may not allow this. (In which case it will be stored temporarely in the unsent_reqs list)

Parameters
reqThe Request

◆ getDownloadRate()

Uint32 bt::PeerDownloader::getDownloadRate ( ) const
overridevirtual

Get the current download rate.

Returns
The download rate in bytes/sec

Implements bt::PieceDownloader.

◆ getName()

QString bt::PeerDownloader::getName ( ) const
overridevirtual

Get the name of the PieceDownloader This is something which can be shown in the GUI. For a regular PeerDownloader, this should be the client and version. For a webseed this should be the URL

Implements bt::PieceDownloader.

◆ hasChunk()

bool bt::PeerDownloader::hasChunk ( Uint32  idx) const
overridevirtual

See if the Peer has a Chunk

Parameters
idxThe Chunk's index

Reimplemented from bt::PieceDownloader.

◆ onRejected

void bt::PeerDownloader::onRejected ( const Request req)
slot

Handles a rejected request.

Parameters
req

◆ piece()

void bt::PeerDownloader::piece ( const Piece p)

Called when a piece has arrived.

Parameters
pThe Piece

◆ update

void bt::PeerDownloader::update ( )
slot

Send requests and manage wait queue


The documentation for this class was generated from the following file: