factor out the tagged hash function used for subshares/blocks
This commit is contained in:
parent
76e28b3484
commit
e7ec4ff4e5
|
@ -95,7 +95,9 @@ class ValidatedBucket:
|
||||||
sht.set_hashes(sh)
|
sht.set_hashes(sh)
|
||||||
self._share_hash = sht.get_leaf(self.sharenum)
|
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
|
# we always validate the blockhash
|
||||||
bh = dict(enumerate(blockhashes))
|
bh = dict(enumerate(blockhashes))
|
||||||
# replace blockhash root with validated value
|
# replace blockhash root with validated value
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from twisted.python import log
|
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.Crypto.Cipher import AES
|
||||||
from allmydata.util import mathutil, hashutil
|
from allmydata.util import mathutil
|
||||||
from allmydata.util.assertutil import _assert
|
from allmydata.util.assertutil import _assert
|
||||||
from allmydata.codec import CRSEncoder
|
from allmydata.codec import CRSEncoder
|
||||||
from allmydata.interfaces import IEncoder
|
from allmydata.interfaces import IEncoder
|
||||||
|
@ -225,7 +225,7 @@ class Encoder(object):
|
||||||
shareid = shareids[i]
|
shareid = shareids[i]
|
||||||
d = self.send_subshare(shareid, segnum, subshare)
|
d = self.send_subshare(shareid, segnum, subshare)
|
||||||
dl.append(d)
|
dl.append(d)
|
||||||
subshare_hash = hashutil.tagged_hash("encoded subshare", subshare)
|
subshare_hash = block_hash(subshare)
|
||||||
self.subshare_hashes[shareid].append(subshare_hash)
|
self.subshare_hashes[shareid].append(subshare_hash)
|
||||||
dl = defer.DeferredList(dl)
|
dl = defer.DeferredList(dl)
|
||||||
def _logit(res):
|
def _logit(res):
|
||||||
|
|
|
@ -436,3 +436,6 @@ class IncompleteHashTree(CompleteBinaryTreeMixin, list):
|
||||||
for i in added:
|
for i in added:
|
||||||
self[i] = None
|
self[i] = None
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def block_hash(data):
|
||||||
|
return tagged_hash("encoded subshare", data)
|
||||||
|
|
Loading…
Reference in New Issue