From d8215e0c6f0ad7468db1003ece7e086669eaf841 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 12 Apr 2007 13:13:25 -0700 Subject: [PATCH] rename chunk.py to hashtree.py --- src/allmydata/download.py | 6 +++--- src/allmydata/encode.py | 2 +- src/allmydata/{chunk.py => hashtree.py} | 0 src/allmydata/test/test_hashtree.py | 18 +++++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) rename src/allmydata/{chunk.py => hashtree.py} (100%) diff --git a/src/allmydata/download.py b/src/allmydata/download.py index 3265184d..57ba5645 100644 --- a/src/allmydata/download.py +++ b/src/allmydata/download.py @@ -7,7 +7,7 @@ from twisted.application import service from allmydata.util import idlib, mathutil, hashutil from allmydata.util.assertutil import _assert -from allmydata import codec, chunk +from allmydata import codec, hashtree from allmydata.Crypto.Cipher import AES from allmydata.uri import unpack_uri from allmydata.interfaces import IDownloadTarget, IDownloader @@ -52,7 +52,7 @@ class ValidatedBucket: self.sharenum = sharenum self.bucket = bucket self.share_hash_tree = share_hash_tree - self.block_hash_tree = chunk.IncompleteHashTree(num_blocks) + self.block_hash_tree = hashtree.IncompleteHashTree(num_blocks) def get_block(self, blocknum): d1 = self.bucket.callRemote('get_block', blocknum) @@ -193,7 +193,7 @@ class FileDownloader: key = "\x00" * 16 self._output = Output(downloadable, key) - self._share_hashtree = chunk.IncompleteHashTree(total_shares) + self._share_hashtree = hashtree.IncompleteHashTree(total_shares) self._share_hashtree.set_hashes({0: roothash}) self.active_buckets = {} # k: shnum, v: bucket diff --git a/src/allmydata/encode.py b/src/allmydata/encode.py index 968adf9f..743e63b8 100644 --- a/src/allmydata/encode.py +++ b/src/allmydata/encode.py @@ -3,7 +3,7 @@ from zope.interface import implements from twisted.internet import defer from twisted.python import log -from allmydata.chunk import HashTree, roundup_pow2 +from allmydata.hashtree import HashTree, roundup_pow2 from allmydata.Crypto.Cipher import AES from allmydata.util import mathutil, hashutil from allmydata.util.assertutil import _assert diff --git a/src/allmydata/chunk.py b/src/allmydata/hashtree.py similarity index 100% rename from src/allmydata/chunk.py rename to src/allmydata/hashtree.py diff --git a/src/allmydata/test/test_hashtree.py b/src/allmydata/test/test_hashtree.py index 1a51c6c6..2349ca2c 100644 --- a/src/allmydata/test/test_hashtree.py +++ b/src/allmydata/test/test_hashtree.py @@ -3,13 +3,13 @@ from twisted.trial import unittest from allmydata.util.hashutil import tagged_hash -from allmydata import chunk +from allmydata import hashtree def make_tree(numleaves): leaves = ["%d" % i for i in range(numleaves)] leaf_hashes = [tagged_hash("tag", leaf) for leaf in leaves] - ht = chunk.HashTree(leaf_hashes) + ht = hashtree.HashTree(leaf_hashes) return ht class Complete(unittest.TestCase): @@ -43,7 +43,7 @@ class Incomplete(unittest.TestCase): # first create a complete hash tree ht = make_tree(6) # then create a corresponding incomplete tree - iht = chunk.IncompleteHashTree(6) + iht = hashtree.IncompleteHashTree(6) # suppose we wanted to validate leaf[0] # leaf[0] is the same as node[7] @@ -61,7 +61,7 @@ class Incomplete(unittest.TestCase): # this should fail because there aren't enough hashes known iht.set_hashes(leaves={0: tagged_hash("tag", "0")}, must_validate=True) - except chunk.NotEnoughHashesError: + except hashtree.NotEnoughHashesError: pass else: self.fail("didn't catch not enough hashes") @@ -76,7 +76,7 @@ class Incomplete(unittest.TestCase): try: # this should fail because the hash is just plain wrong iht.set_hashes(leaves={0: tagged_hash("bad tag", "0")}) - except chunk.BadHashError: + except hashtree.BadHashError: pass else: self.fail("didn't catch bad hash") @@ -84,20 +84,20 @@ class Incomplete(unittest.TestCase): try: # this should succeed iht.set_hashes(leaves={0: tagged_hash("tag", "0")}) - except chunk.BadHashError, e: + except hashtree.BadHashError, e: self.fail("bad hash: %s" % e) try: # this should succeed too iht.set_hashes(leaves={1: tagged_hash("tag", "1")}) - except chunk.BadHashError: + except hashtree.BadHashError: self.fail("bad hash") # giving it a bad internal hash should also cause problems iht.set_hashes({13: tagged_hash("bad tag", "x")}) try: iht.set_hashes({14: tagged_hash("tag", "14")}) - except chunk.BadHashError: + except hashtree.BadHashError: pass else: self.fail("didn't catch bad hash") @@ -110,6 +110,6 @@ class Incomplete(unittest.TestCase): try: # this should succeed iht.set_hashes(leaves={4: tagged_hash("tag", "4")}) - except chunk.BadHashError, e: + except hashtree.BadHashError, e: self.fail("bad hash: %s" % e) -- 2.45.2