diff --git a/ChangeLog b/ChangeLog index 6006772b..c5a2679a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-01-12 Tatsuhiro Tsujikawa + + Use BencodeVisitor and MessageDigestHelper instead of ShaVisitor. + ShaVisitor is now deprecated and slated to be removed. + * src/DefaultBtContext.cc + 2008-01-12 Tatsuhiro Tsujikawa Externalize message to message.h diff --git a/src/DefaultBtContext.cc b/src/DefaultBtContext.cc index 15fc0412..1bc0dd72 100644 --- a/src/DefaultBtContext.cc +++ b/src/DefaultBtContext.cc @@ -38,7 +38,7 @@ #include "List.h" #include "Data.h" #include "DlAbortEx.h" -#include "ShaVisitor.h" +#include "BencodeVisitor.h" #include "Util.h" #include "MessageDigestHelper.h" #include "a2netcompat.h" @@ -254,10 +254,11 @@ void DefaultBtContext::processRootDictionary(const Dictionary* rootDic, const st throw new DlAbortEx(MSG_SOMETHING_MISSING_IN_TORRENT, "info directory"); } // retrieve infoHash - ShaVisitor v; + BencodeVisitor v; infoDic->accept(&v); - int len; - v.getHash(infoHash, len); + MessageDigestHelper::digest(infoHash, INFO_HASH_LENGTH, "sha1", + v.getBencodedData().c_str(), + v.getBencodedData().size()); infoHashString = Util::toHex(infoHash, INFO_HASH_LENGTH); // calculate the number of pieces const Data* pieceHashData = dynamic_cast(infoDic->get("pieces"));