Bladeren bron

Renamed DownloadResult::infoHashStr to infoHash and changed its
contents from hex digest to raw byte string.

Tatsuhiro Tsujikawa 14 jaren geleden
bovenliggende
commit
6404f119e1
3 gewijzigde bestanden met toevoegingen van 5 en 4 verwijderingen
  1. 1 1
      src/DownloadResult.h
  2. 2 1
      src/RequestGroup.cc
  3. 2 2
      src/RpcMethodImpl.cc

+ 1 - 1
src/DownloadResult.h

@@ -87,7 +87,7 @@ struct DownloadResult
 
   std::string bitfieldStr;
 
-  std::string infoHashStr;
+  std::string infoHash;
 
   size_t pieceLength;
 

+ 2 - 1
src/RequestGroup.cc

@@ -1188,7 +1188,8 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
   }
 #ifdef ENABLE_BITTORRENT
   if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
-    res->infoHashStr = bittorrent::getInfoHashString(downloadContext_);
+    const unsigned char* p = bittorrent::getInfoHash(downloadContext_);
+    res->infoHash = std::string(p, p+INFO_HASH_LENGTH);
   }
 #endif // ENABLE_BITTORRENT
   res->pieceLength = downloadContext_->getPieceLength();

+ 2 - 2
src/RpcMethodImpl.cc

@@ -891,9 +891,9 @@ void gatherStoppedDownload
   if(requested_key(keys, KEY_UPLOAD_SPEED)) {
     entryDict->put(KEY_UPLOAD_SPEED, VLB_ZERO);
   }
-  if(!ds->infoHashStr.empty()) {
+  if(!ds->infoHash.empty()) {
     if(requested_key(keys, KEY_INFO_HASH)) {
-      entryDict->put(KEY_INFO_HASH, ds->infoHashStr);
+      entryDict->put(KEY_INFO_HASH, util::toHex(ds->infoHash));
     }
     if(requested_key(keys, KEY_NUM_SEEDERS)) {
       entryDict->put(KEY_NUM_SEEDERS, VLB_ZERO);