From: Brian Warner Date: Wed, 18 Apr 2007 03:27:56 +0000 (-0700) Subject: factor out the tagged hash function used for subshares/blocks X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~73 X-Git-Url: https://git.rkrishnan.org/pf/content/en/footer/legal.html?a=commitdiff_plain;h=e7ec4ff4e5599592ad24afd2fca0a3a5294b4cc2;p=tahoe-lafs%2Ftahoe-lafs.git factor out the tagged hash function used for subshares/blocks --- diff --git a/src/allmydata/download.py b/src/allmydata/download.py index 44076caf..ddc3678b 100644 --- a/src/allmydata/download.py +++ b/src/allmydata/download.py @@ -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 diff --git a/src/allmydata/encode.py b/src/allmydata/encode.py index cc3c4f39..5b74f107 100644 --- a/src/allmydata/encode.py +++ b/src/allmydata/encode.py @@ -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): diff --git a/src/allmydata/hashtree.py b/src/allmydata/hashtree.py index 63816f5e..c03c90d0 100644 --- a/src/allmydata/hashtree.py +++ b/src/allmydata/hashtree.py @@ -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)