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
pull/1/head
Tatsuhiro Tsujikawa 2008-01-11 15:47:31 +00:00
parent 160d5a8614
commit a548f956fe
2 changed files with 11 additions and 4 deletions

View File

@ -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> 2008-01-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Externalize message to message.h Externalize message to message.h

View File

@ -38,7 +38,7 @@
#include "List.h" #include "List.h"
#include "Data.h" #include "Data.h"
#include "DlAbortEx.h" #include "DlAbortEx.h"
#include "ShaVisitor.h" #include "BencodeVisitor.h"
#include "Util.h" #include "Util.h"
#include "MessageDigestHelper.h" #include "MessageDigestHelper.h"
#include "a2netcompat.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"); throw new DlAbortEx(MSG_SOMETHING_MISSING_IN_TORRENT, "info directory");
} }
// retrieve infoHash // retrieve infoHash
ShaVisitor v; BencodeVisitor v;
infoDic->accept(&v); infoDic->accept(&v);
int len; MessageDigestHelper::digest(infoHash, INFO_HASH_LENGTH, "sha1",
v.getHash(infoHash, len); v.getBencodedData().c_str(),
v.getBencodedData().size());
infoHashString = Util::toHex(infoHash, INFO_HASH_LENGTH); infoHashString = Util::toHex(infoHash, INFO_HASH_LENGTH);
// calculate the number of pieces // calculate the number of pieces
const Data* pieceHashData = dynamic_cast<const Data*>(infoDic->get("pieces")); const Data* pieceHashData = dynamic_cast<const Data*>(infoDic->get("pieces"));