libktorrent  2.2.0
Public Member Functions | Friends | List of all members
bt::ChunkDownload Class Reference

Handles the download off one Chunk off a Peer. More...

#include <chunkdownload.h>

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

Public Member Functions

 ChunkDownload (Chunk *chunk)
 
bool assign (PieceDownloader *pd)
 
Uint32 bytesDownloaded () const
 Get the number of bytes downloaded.
 
void cancelAll ()
 
bool containsPeer (PieceDownloader *pd)
 See if a PieceDownloader is assigned to this chunk.
 
ChunkgetChunk ()
 Get the chunk.
 
Uint32 getChunkIndex () const
 Get the index of the chunk.
 
Uint32 getDownloadSpeed () const
 Get the download speed.
 
SHA1Hash getHash () const
 Get the SHA1 hash of the downloaded chunk.
 
Uint32 getNumDownloaders () const
 Get the number of downloaders.
 
PieceDownloadergetOnlyDownloader ()
 
QString getPieceDownloaderName () const
 Get the PeerID of the current peer.
 
Uint32 getPiecesDownloaded () const
 Get the number of pieces downloaded.
 
void getStats (Stats &s) override
 Get download stats.
 
Uint32 getTotalPieces () const
 Get the total number of pieces.
 
bool isChoked () const
 See if the download is choked (i.e. all downloaders are choked)
 
bool isIdle () const
 See if a chunkdownload is idle (i.e. has no downloaders)
 
void killed (PieceDownloader *pd)
 
bool load (File &file, ChunkDownloadHeader &hdr, bool update_hash=true)
 
bool needsToBeUpdated () const
 See if this CD hasn't been active in the last update.
 
bool piece (const Piece &p, bool &ok)
 
void release (PieceDownloader *pd)
 
void releaseAllPDs ()
 Release all PD's and clear the requested chunks.
 
void save (File &file)
 
void update ()
 Send requests to peers.
 

Friends

Fileoperator<< (File &out, const ChunkDownload &cd)
 
Fileoperator>> (File &in, ChunkDownload &cd)
 

Detailed Description

Author
Joris Guisson

This class handles the download of one Chunk.

Definition at line 89 of file chunkdownload.h.

Constructor & Destructor Documentation

◆ ChunkDownload()

bt::ChunkDownload::ChunkDownload ( Chunk chunk)

Constructor, set the chunk and the PeerManager.

Parameters
chunkThe Chunk

Member Function Documentation

◆ assign()

bool bt::ChunkDownload::assign ( PieceDownloader pd)

Assign the downloader to download from.

Parameters
pdThe downloader
Returns
true if the peer was asigned, false if not

◆ cancelAll()

void bt::ChunkDownload::cancelAll ( )

Cancel all requests.

◆ getOnlyDownloader()

PieceDownloader* bt::ChunkDownload::getOnlyDownloader ( )

When a Chunk is downloaded, this function checks if all pieces are delivered by the same peer and if so returns it.

Returns
The PieceDownloader or 0 if there is no only peer

◆ killed()

void bt::ChunkDownload::killed ( PieceDownloader pd)

A PieceDownloader has been killed. We need to remove it.

Parameters
pdThe PieceDownloader

◆ load()

bool bt::ChunkDownload::load ( File file,
ChunkDownloadHeader hdr,
bool  update_hash = true 
)

Load from a File

Parameters
fileThe File
hdrHeader for the chunk
update_hashWhether or not to update the hash

◆ piece()

bool bt::ChunkDownload::piece ( const Piece p,
bool &  ok 
)

A Piece has arived.

Parameters
pThe Piece
okWhether or not the piece was needed
Returns
true If Chunk is complete

◆ release()

void bt::ChunkDownload::release ( PieceDownloader pd)

Release a downloader

Parameters
pdThe downloader

◆ save()

void bt::ChunkDownload::save ( File file)

Save to a File

Parameters
fileThe File

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