rename TorrentMan::downloadedSize to TorrentMan::downloadLength

This commit is contained in:
Tatsuhiro Tsujikawa 2006-03-31 14:58:36 +00:00
parent 133f759a0d
commit 8b94be7475
5 changed files with 17 additions and 17 deletions

View File

@ -81,7 +81,7 @@ bool PeerInteractionCommand::executeInternal() {
peer->ipaddr.c_str(), peer->port,
handshakeMessage->toString().c_str());
delete handshakeMessage;
if(e->torrentMan->getDownloadedSize() > 0) {
if(e->torrentMan->getDownloadLength() > 0) {
peerConnection->sendBitfield();
}
sequence = WIRED;
@ -98,7 +98,7 @@ bool PeerInteractionCommand::executeInternal() {
handshakeMessage->toString().c_str());
delete handshakeMessage;
peerConnection->sendHandshake();
if(e->torrentMan->getDownloadedSize() > 0) {
if(e->torrentMan->getDownloadLength() > 0) {
peerConnection->sendBitfield();
}
sequence = WIRED;

View File

@ -33,10 +33,10 @@ void TorrentConsoleDownloadEngine::printStatistics() {
printf("Download Completed ");
} else {
printf("%s/%sB %d%% DW:%.2f",
Util::llitos(torrentMan->getDownloadedSize(), true).c_str(),
Util::llitos(torrentMan->getDownloadLength(), true).c_str(),
Util::llitos(torrentMan->totalSize, true).c_str(),
(torrentMan->totalSize == 0 ?
0 : (int)((torrentMan->getDownloadedSize()*100)/torrentMan->totalSize)),
0 : (int)((torrentMan->getDownloadLength()*100)/torrentMan->totalSize)),
downloadSpeed/1000.0);
}
printf(" UP:%.2f(%s) %dpeers",

View File

@ -35,7 +35,7 @@
TorrentMan::TorrentMan():bitfield(NULL),
peerEntryIdCounter(0), cuidCounter(0),
downloadedSize(0), uploadedSize(0),
downloadLength(0), uploadedSize(0),
preDownloadedSize(0), preUploadedSize(0),
deltaDownload(0), deltaUpload(0),
storeDir("."),
@ -226,7 +226,7 @@ void TorrentMan::completePiece(const Piece& piece) {
return;
}
if(!hasPiece(piece.getIndex())) {
addDownloadedSize(piece.getLength());
addDownloadLength(piece.getLength());
}
bitfield->setBit(piece.getIndex());
bitfield->unsetUseBit(piece.getIndex());
@ -302,7 +302,7 @@ void TorrentMan::setup(string metaInfoFile) {
}
uploadedSize = 0;
downloadedSize = 0;
downloadLength = 0;
Dictionary* topDic = (Dictionary*)MetaFileUtil::parseMetaFile(metaInfoFile);
const Dictionary* infoDic = (const Dictionary*)topDic->get("info");
ShaVisitor v;
@ -445,13 +445,13 @@ void TorrentMan::read(FILE* file) {
throw new DlAbortEx(strerror(errno));
}
setBitfield(savedBitfield, bitfield->getBitfieldLength());
if(fread(&downloadedSize, sizeof(downloadedSize), 1, file) < 1) {
if(fread(&downloadLength, sizeof(downloadLength), 1, file) < 1) {
throw new DlAbortEx(strerror(errno));
}
if(fread(&uploadedSize, sizeof(uploadedSize), 1, file) < 1) {
throw new DlAbortEx(strerror(errno));
}
preDownloadedSize = downloadedSize;
preDownloadedSize = downloadLength;
preUploadedSize = uploadedSize;
delete [] savedBitfield;
} catch(Exception* ex) {
@ -473,7 +473,7 @@ void TorrentMan::save() const {
if(fwrite(bitfield->getBitfield(), bitfield->getBitfieldLength(), 1, file) < 1) {
throw new DlAbortEx(strerror(errno));
}
if(fwrite(&downloadedSize, sizeof(downloadedSize), 1, file) < 1) {
if(fwrite(&downloadLength, sizeof(downloadLength), 1, file) < 1) {
throw new DlAbortEx(strerror(errno));
}
if(fwrite(&uploadedSize, sizeof(uploadedSize), 1, file) < 1) {

View File

@ -73,7 +73,7 @@ private:
deque<string> pieceHashes;
int peerEntryIdCounter;
int cuidCounter;
long long int downloadedSize;
long long int downloadLength;
long long int uploadedSize;
long long int preDownloadedSize;
long long int preUploadedSize;
@ -181,16 +181,16 @@ public:
int getDeltaUpload() const { return deltaUpload; }
void resetDeltaUpload() { deltaUpload = 0; }
void addDownloadedSize(int size) { downloadedSize += size; }
long long int getDownloadedSize() const { return downloadedSize; }
void setDownloadedSize(long long int size) { downloadedSize = size; }
void addDownloadLength(int deltaLength) { downloadLength += deltaLength; }
long long int getDownloadLength() const { return downloadLength; }
void setDownloadLength(long long int length) { downloadLength = length; }
void addUploadedSize(int size) { uploadedSize += size; }
long long int getUploadedSize() const { return uploadedSize; }
void setUploadedSize(long long int size) { uploadedSize = size; }
long long int getSessionDownloadedSize() const {
return downloadedSize-preDownloadedSize;
return downloadLength-preDownloadedSize;
}
long long int getSessionUploadedSize() const {
return uploadedSize-preUploadedSize;

View File

@ -59,8 +59,8 @@ bool TrackerInitCommand::execute() {
"port="+Util::itos(e->torrentMan->getPort())+"&"+
"uploaded="+Util::llitos(e->torrentMan->getSessionUploadedSize())+"&"+
"downloaded="+Util::llitos(e->torrentMan->getSessionDownloadedSize())+"&"+
"left="+(e->torrentMan->totalSize-e->torrentMan->getDownloadedSize() <= 0
? "0" : Util::llitos(e->torrentMan->totalSize-e->torrentMan->getDownloadedSize()))+"&"+
"left="+(e->torrentMan->totalSize-e->torrentMan->getDownloadLength() <= 0
? "0" : Util::llitos(e->torrentMan->totalSize-e->torrentMan->getDownloadLength()))+"&"+
"compact=1";
if(!event.empty()) {
url += string("&")+"event="+event;