summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-07-27 22:50:10 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-07-27 22:50:10 +0900
commit02292feaba560e379acec7f7477a0c50c679d0dc (patch)
tree26959c29862865642da6cc62975692896f0248f7
parent03f0774482075c9777ad5733e7e285d792a76360 (diff)
Consistent naming scheme for hash type and digest for Piece.
-rw-r--r--src/DefaultBtProgressInfoFile.cc2
-rw-r--r--src/DefaultPieceStorage.cc4
-rw-r--r--src/Piece.cc8
-rw-r--r--src/Piece.h4
-rw-r--r--test/PieceTest.cc2
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<Piece> 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<MessageDigest> 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