From 02292feaba560e379acec7f7477a0c50c679d0dc Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 27 Jul 2011 22:50:10 +0900 Subject: [PATCH] Consistent naming scheme for hash type and digest for Piece. --- src/DefaultBtProgressInfoFile.cc | 2 +- src/DefaultPieceStorage.cc | 4 ++-- src/Piece.cc | 8 ++++---- src/Piece.h | 4 ++-- test/PieceTest.cc | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index ada93585..2b816817 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -390,7 +390,7 @@ void DefaultBtProgressInfoFile::load() #ifdef ENABLE_MESSAGE_DIGEST - piece->setHashAlgo(dctx_->getPieceHashType()); + piece->setHashType(dctx_->getPieceHashType()); #endif // ENABLE_MESSAGE_DIGEST diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index 8c683af5..eedce97f 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -106,7 +106,7 @@ SharedHandle DefaultPieceStorage::checkOutPiece piece.reset(new Piece(index, bitfieldMan_->getBlockLength(index))); #ifdef ENABLE_MESSAGE_DIGEST - piece->setHashAlgo(downloadContext_->getPieceHashType()); + piece->setHashType(downloadContext_->getPieceHashType()); #endif // ENABLE_MESSAGE_DIGEST @@ -735,7 +735,7 @@ void DefaultPieceStorage::markPiecesDone(uint64_t length) #ifdef ENABLE_MESSAGE_DIGEST - p->setHashAlgo(downloadContext_->getPieceHashType()); + p->setHashType(downloadContext_->getPieceHashType()); #endif // ENABLE_MESSAGE_DIGEST diff --git a/src/Piece.cc b/src/Piece.cc index c2734123..f6f8c63a 100644 --- a/src/Piece.cc +++ b/src/Piece.cc @@ -190,20 +190,20 @@ size_t Piece::getCompletedLength() #ifdef ENABLE_MESSAGE_DIGEST -void Piece::setHashAlgo(const std::string& algo) +void Piece::setHashType(const std::string& hashType) { - hashAlgo_ = algo; + hashType_ = hashType; } bool Piece::updateHash (uint32_t begin, const unsigned char* data, size_t dataLength) { - if(hashAlgo_.empty()) { + if(hashType_.empty()) { return false; } if(begin == nextBegin_ && nextBegin_+dataLength <= length_) { if(!mdctx_) { - mdctx_ = MessageDigest::create(hashAlgo_); + mdctx_ = MessageDigest::create(hashType_); } mdctx_->update(data, dataLength); nextBegin_ += dataLength; diff --git a/src/Piece.h b/src/Piece.h index 8e824c68..128c83a1 100644 --- a/src/Piece.h +++ b/src/Piece.h @@ -66,7 +66,7 @@ private: size_t nextBegin_; - std::string hashAlgo_; + std::string hashType_; SharedHandle mdctx_; @@ -155,7 +155,7 @@ public: #ifdef ENABLE_MESSAGE_DIGEST - void setHashAlgo(const std::string& algo); + void setHashType(const std::string& hashType); // Updates hash value. This function compares begin and private variable // nextBegin_ and only when they are equal, hash is updated eating data and diff --git a/test/PieceTest.cc b/test/PieceTest.cc index d0cea08a..e714952e 100644 --- a/test/PieceTest.cc +++ b/test/PieceTest.cc @@ -65,7 +65,7 @@ void PieceTest::testGetCompletedLength() void PieceTest::testUpdateHash() { Piece p(0, 16, 2*1024*1024); - p.setHashAlgo("sha-1"); + p.setHashType("sha-1"); std::string spam("SPAM!"); CPPUNIT_ASSERT(p.updateHash