diff --git a/src/allmydata/immutable/checker.py b/src/allmydata/immutable/checker.py
index c565bc3..77edff8 100644
a
|
b
|
class Checker(log.PrefixingLogMixin): |
159 | 159 | self._share_hash_tree = hashtree.IncompleteHashTree(self._verifycap.total_shares) |
160 | 160 | self._share_hash_tree.set_hashes({0: vup.share_root_hash}) |
161 | 161 | |
162 | | vrbp = download.ValidatedReadBucketProxy(sharenum, b, self._share_hash_tree, vup.num_segments, vup.block_size, vup.share_size) |
| 162 | vrbp = download.ValidatedReadBucketProxy(sharenum, b, self._share_hash_tree, vup.num_segments, vup.block_size, vup.share_size, self._verifycap.storage_index) |
163 | 163 | |
164 | 164 | ds = [] |
165 | 165 | for blocknum in range(vup.num_segments): |
diff --git a/src/allmydata/immutable/download.py b/src/allmydata/immutable/download.py
index 9dfc0bb..efb5454 100644
a
|
b
|
class ValidatedReadBucketProxy(log.PrefixingLogMixin): |
318 | 318 | My get_block() method is used by BlockDownloaders. |
319 | 319 | """ |
320 | 320 | |
321 | | def __init__(self, sharenum, bucket, share_hash_tree, num_blocks, block_size, share_size): |
| 321 | def __init__(self, sharenum, bucket, share_hash_tree, num_blocks, block_size, share_size, |
| 322 | storage_index): |
322 | 323 | """ share_hash_tree is required to have already been initialized with the root hash |
323 | 324 | (the number-0 hash), using the share_root_hash from the UEB """ |
324 | 325 | precondition(share_hash_tree[0] is not None, share_hash_tree) |
… |
… |
class ValidatedReadBucketProxy(log.PrefixingLogMixin): |
331 | 332 | self.block_size = block_size |
332 | 333 | self.share_size = share_size |
333 | 334 | self.block_hash_tree = hashtree.IncompleteHashTree(self.num_blocks) |
| 335 | self.storage_index = storage_index |
334 | 336 | |
335 | 337 | def get_block(self, blocknum): |
336 | 338 | # the first time we use this bucket, we need to fetch enough elements |
… |
… |
class ValidatedReadBucketProxy(log.PrefixingLogMixin): |
408 | 410 | # likely a programming error |
409 | 411 | self.log("hash failure in block=%d, shnum=%d on %s" % |
410 | 412 | (blocknum, self.sharenum, self.bucket)) |
| 413 | try: |
| 414 | fn = ("logs/badhash-from-%s-SI-%s-shnum-%d-blocknum-%d" % |
| 415 | (idlib.shortnodeid_b2a(self.bucket._peerid), |
| 416 | base32.b2a(self.storage_index), self.sharenum, blocknum)) |
| 417 | f = open(fn, "wb") |
| 418 | f.write(blockdata) |
| 419 | f.close() |
| 420 | except Exception, e: |
| 421 | self.log(" (unable to write blockdata: %s)" % (e,)) |
411 | 422 | if self.block_hash_tree.needed_hashes(blocknum): |
412 | 423 | self.log(""" failure occurred when checking the block_hash_tree. |
413 | 424 | This suggests that either the block data was bad, or that the |
… |
… |
class CiphertextDownloader(log.PrefixingLogMixin): |
923 | 934 | |
924 | 935 | def _download_all_segments(self, res): |
925 | 936 | for sharenum, bucket in self._share_buckets: |
926 | | vbucket = ValidatedReadBucketProxy(sharenum, bucket, self._share_hash_tree, self._vup.num_segments, self._vup.block_size, self._vup.share_size) |
| 937 | vbucket = ValidatedReadBucketProxy(sharenum, bucket, self._share_hash_tree, |
| 938 | self._vup.num_segments, |
| 939 | self._vup.block_size, self._vup.share_size, |
| 940 | self._storage_index) |
927 | 941 | self._share_vbuckets.setdefault(sharenum, set()).add(vbucket) |
928 | 942 | |
929 | 943 | # after the above code, self._share_vbuckets contains enough |