From: Cameron Dale Date: Tue, 11 Mar 2008 18:40:43 +0000 (-0700) Subject: Fix minor bugs in the use of sha module and misspelled b2a_hex. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6b20da2c3d8e24161be0937bcaac2b351801b445;p=quix0rs-apt-p2p.git Fix minor bugs in the use of sha module and misspelled b2a_hex. --- diff --git a/apt_p2p/apt_p2p.py b/apt_p2p/apt_p2p.py index 9e360a0..83f7c2f 100644 --- a/apt_p2p/apt_p2p.py +++ b/apt_p2p/apt_p2p.py @@ -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 diff --git a/apt_p2p/db.py b/apt_p2p/db.py index 396f419..63cc7e7 100644 --- a/apt_p2p/db.py +++ b/apt_p2p/db.py @@ -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()