Przeglądaj źródła

2008-01-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Use BencodeVisitor and MessageDigestHelper instead of 
ShaVisitor.
	ShaVisitor is now deprecated and slated to be removed.
	* src/DefaultBtContext.cc
Tatsuhiro Tsujikawa 18 lat temu
rodzic
commit
a548f956fe
2 zmienionych plików z 11 dodań i 4 usunięć
  1. 6 0
      ChangeLog
  2. 5 4
      src/DefaultBtContext.cc

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2008-01-12  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Use BencodeVisitor and MessageDigestHelper instead of ShaVisitor.
+	ShaVisitor is now deprecated and slated to be removed.
+	* src/DefaultBtContext.cc
+
 2008-01-12  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Externalize message to message.h

+ 5 - 4
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<const Data*>(infoDic->get("pieces"));