20 #ifndef BTCHUNKDOWNLOAD_H
21 #define BTCHUNKDOWNLOAD_H
26 #include <util/timer.h>
27 #include <util/ptrmap.h>
28 #include <util/sha1hashgen.h>
29 #include <interfaces/chunkdownloadinterface.h>
30 #include <util/bitset.h>
31 #include <diskio/piecedata.h>
42 class PieceDownloader;
65 void remove(Uint32 p);
66 bool contains(Uint32 p);
69 void timeout() {timeouts++;}
70 Uint32 numTimeouts()
const {
return timeouts;}
72 typedef QSet<Uint32>::iterator iterator;
73 iterator begin() {
return status.begin();}
74 iterator end() {
return status.end();}
126 bool isIdle()
const {
return pdown.count() == 0;}
207 void notDownloaded(
const Request & r,
bool reject);
212 void endgameCancel(
const Piece & p);
219 Uint32 num_downloaded;
222 QList<PieceDownloader*> pdown;
224 QSet<PieceDownloader*> piece_providers;
225 PieceData::Ptr* piece_data;
227 Uint32 num_pieces_in_hash;
bool load(File &file, ChunkDownloadHeader &hdr, bool update_hash=true)
Simple implementation of a BitSet.
void release(PieceDownloader *pd)
void update()
Send requests to peers.
void killed(PieceDownloader *pd)
Keep track of a piece of the file.
QString getPieceDownloaderName() const
Get the PeerID of the current peer.
SHA1Hash getHash() const
Get the SHA1 hash of the downloaded chunk.
Wrapper class for stdio's FILE.
Interface for a ChunkDownload.
bool needsToBeUpdated() const
See if this CD hasn't been active in the last update.
Uint32 getTotalPieces() const
Get the total number of pieces.
bool containsPeer(PieceDownloader *pd)
See if a PieceDownloader is assigned to this chunk.
Request of a piece sent to other peers.
Uint32 getChunkIndex() const
Get the index of the chunk.
bool isChoked() const
See if the download is choked (i.e. all downloaders are choked)
Chunk * getChunk()
Get the chunk.
Uint32 getDownloadSpeed() const
Get the download speed.
void releaseAllPDs()
Release all PD's and clear the requested chunks.
PieceDownloader * getOnlyDownloader()
bool isIdle() const
See if a chunkdownload is idle (i.e. has no downloaders)
Uint32 bytesDownloaded() const
Get the number of bytes downloaded.
Uint32 getPiecesDownloaded() const
Get the number of pieces downloaded.
void getStats(Stats &s) override
Get download stats.
bool piece(const Piece &p, bool &ok)
Uint32 getNumDownloaders() const
Get the number of downloaders.
ChunkDownload(Chunk *chunk)
Handles the download off one Chunk off a Peer.
bool assign(PieceDownloader *pd)