]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
factor out the tagged hash function used for subshares/blocks
authorBrian Warner <warner@allmydata.com>
Wed, 18 Apr 2007 03:27:56 +0000 (20:27 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 18 Apr 2007 03:27:56 +0000 (20:27 -0700)
src/allmydata/download.py
src/allmydata/encode.py
src/allmydata/hashtree.py

index 44076cafd7e98a36e863bd6a45bf568a139e100b..ddc3678b7023db88bb58d236c1f036abc3097130 100644 (file)
@@ -95,7 +95,9 @@ class ValidatedBucket:
                 sht.set_hashes(sh)
                 self._share_hash = sht.get_leaf(self.sharenum)
 
-            blockhash = hashutil.tagged_hash("encoded subshare", blockdata)
+            #log.msg("checking block_hash(shareid=%d, blocknum=%d) len=%d" %
+            #        (self.sharenum, blocknum, len(blockdata)))
+            blockhash = hashtree.block_hash(blockdata)
             # we always validate the blockhash
             bh = dict(enumerate(blockhashes))
             # replace blockhash root with validated value
index cc3c4f39aa69568acddba336b7d396d462182dbc..5b74f107a2c14acf1b8d7a54bec1ee27ba641349 100644 (file)
@@ -3,9 +3,9 @@
 from zope.interface import implements
 from twisted.internet import defer
 from twisted.python import log
-from allmydata.hashtree import HashTree
+from allmydata.hashtree import HashTree, block_hash
 from allmydata.Crypto.Cipher import AES
-from allmydata.util import mathutil, hashutil
+from allmydata.util import mathutil
 from allmydata.util.assertutil import _assert
 from allmydata.codec import CRSEncoder
 from allmydata.interfaces import IEncoder
@@ -225,7 +225,7 @@ class Encoder(object):
             shareid = shareids[i]
             d = self.send_subshare(shareid, segnum, subshare)
             dl.append(d)
-            subshare_hash = hashutil.tagged_hash("encoded subshare", subshare)
+            subshare_hash = block_hash(subshare)
             self.subshare_hashes[shareid].append(subshare_hash)
         dl = defer.DeferredList(dl)
         def _logit(res):
index 63816f5ed410d6fd1252ce7a0a2c488e8f73fbe4..c03c90d023e6f8203c5f31134eacfa625c2e005d 100644 (file)
@@ -436,3 +436,6 @@ class IncompleteHashTree(CompleteBinaryTreeMixin, list):
             for i in added:
                 self[i] = None
             raise
+
+def block_hash(data):
+    return tagged_hash("encoded subshare", data)