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;
44 struct ChunkDownloadHeader
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();}
102 Chunk* getChunk() {
return chunk;}
105 Uint32 getTotalPieces()
const {
return num;}
108 Uint32 getPiecesDownloaded()
const {
return num_downloaded;}
111 Uint32 bytesDownloaded()
const;
114 Uint32 getChunkIndex()
const;
117 QString getPieceDownloaderName()
const;
120 Uint32 getDownloadSpeed()
const;
126 bool isIdle()
const {
return pdown.count() == 0;}
134 bool piece(
const Piece & p,
bool & ok);
185 bool isChoked()
const;
188 void releaseAllPDs();
194 bool needsToBeUpdated()
const {
return timer.getElapsedSinceUpdate() > 60 * 1000;}
200 Uint32 getNumDownloaders()
const {
return pdown.count();}
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;