]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Fix minor bugs in the use of sha module and misspelled b2a_hex.
authorCameron Dale <camrdale@gmail.com>
Tue, 11 Mar 2008 18:40:43 +0000 (11:40 -0700)
committerCameron Dale <camrdale@gmail.com>
Tue, 11 Mar 2008 18:40:43 +0000 (11:40 -0700)
apt_p2p/apt_p2p.py
apt_p2p/db.py

index 9e360a00d62acc08605e5957f4007003d216ed0a..83f7c2f84363da4cb6f17efcd4fd87324794378d 100644 (file)
@@ -336,12 +336,10 @@ class AptP2P:
             value['t'] = {'t': ''.join(pieces)}
         elif len(pieces) <= TORRENT_PIECES:
             # Short enough to be stored in a separate key in the DHT
-            s = sha.new().update(''.join(pieces))
-            value['h'] = s.digest()
+            value['h'] = sha.new(''.join(pieces)).digest()
         else:
             # Too long, must be served up by our peer HTTP server
-            s = sha.new().update(''.join(pieces))
-            value['l'] = s.digest()
+            value['l'] = sha.new(''.join(pieces)).digest()
 
         storeDefer = self.dht.storeValue(key, value)
         storeDefer.addCallback(self.store_done, hash)
@@ -353,8 +351,7 @@ class AptP2P:
         pieces = hash.pieceDigests()
         if len(pieces) > DHT_PIECES and len(pieces) <= TORRENT_PIECES:
             # Add the piece data key and value to the DHT
-            s = sha.new().update(''.join(pieces))
-            key = s.digest()
+            key = sha.new(''.join(pieces)).digest()
             value = {'t': ''.join(pieces)}
 
             storeDefer = self.dht.storeValue(key, value)
@@ -364,6 +361,6 @@ class AptP2P:
 
     def store_torrent_done(self, result, key):
         """Adding the file to the DHT is complete, and so is the workflow."""
-        log.msg('Added torrent string %s to the DHT: %r' % (b2ahex(key), result))
+        log.msg('Added torrent string %s to the DHT: %r' % (b2a_hex(key), result))
         return result
     
\ No newline at end of file
index 396f419da12b791d5f2ce0408ce6ce2e79a700e0..63cc7e72cbc8f783030afe593c8464b708433f14 100644 (file)
@@ -114,8 +114,7 @@ class DB:
         # Hash the pieces to get the piecehash
         piecehash = ''
         if pieces:
-            s = sha.new().update(pieces)
-            piecehash = sha.digest()
+            piecehash = sha.new(pieces).digest()
             
         # Check the database for the hash
         c = self.conn.cursor()