]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
encode_new.py: rearrange methods into the order in which they should be called
authorBrian Warner <warner@allmydata.com>
Wed, 28 Mar 2007 20:30:17 +0000 (13:30 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 28 Mar 2007 20:30:17 +0000 (13:30 -0700)
src/allmydata/encode_new.py

index 88ca52af2e77d0a1c364654f50a0cc389b492663..5b8a784cc39229bb73b1ff7ae05899370e61710a 100644 (file)
@@ -92,27 +92,14 @@ class Encoder(object):
         self.segment_size = min(2*MiB, self.file_size)
         self.num_segments = mathutil.div_ceil(self.file_size, self.segment_size)
 
-    def setup_encoder(self):
-        self.encoder = CRSEncoder()
-        self.encoder.set_params(self.segment_size, self.required_shares,
-                                self.num_shares)
-
     def get_reservation_size(self):
         self.num_shares = 100
         self.share_size = mathutil.div_ceil(self.file_size, self.required_shares)
         overhead = self.compute_overhead()
         return self.share_size + overhead
 
-    def setup_encryption(self):
-        self.key = "\x00"*16
-        self.cryptor = AES.new(key=self.key, mode=AES.MODE_CTR,
-                               counterstart="\x00"*16)
-        self.segment_num = 0
-        self.subshare_hashes = [[] for x in range(self.num_shares)]
-        # subshare_hashes[i] is a list that will be accumulated and then send
-        # to landlord[i]. This list contains a hash of each segment_share
-        # that we sent to that landlord.
-        self.share_root_hashes = [None] * self.num_shares
+    def set_shareholders(self, landlords):
+        self.landlords = landlords.copy()
 
     def start(self):
         self.setup_encryption()
@@ -126,6 +113,22 @@ class Encoder(object):
         d.addCallback(lambda res: self.done())
         return d
 
+    def setup_encryption(self):
+        self.key = "\x00"*16
+        self.cryptor = AES.new(key=self.key, mode=AES.MODE_CTR,
+                               counterstart="\x00"*16)
+        self.segment_num = 0
+        self.subshare_hashes = [[] for x in range(self.num_shares)]
+        # subshare_hashes[i] is a list that will be accumulated and then send
+        # to landlord[i]. This list contains a hash of each segment_share
+        # that we sent to that landlord.
+        self.share_root_hashes = [None] * self.num_shares
+
+    def setup_encoder(self):
+        self.encoder = CRSEncoder()
+        self.encoder.set_params(self.segment_size, self.required_shares,
+                                self.num_shares)
+
     def do_segment(self, segnum):
         chunks = []
         # the ICodecEncoder API wants to receive a total of self.segment_size
@@ -172,9 +175,6 @@ class Encoder(object):
         #    return self.send(shareid, "write", subshare, offset)
         return self.send(shareid, "put_subshare", segment_num, subshare)
 
-    def set_landlords(self, landlords):
-        self.landlords = landlords.copy()
-
     def send(self, shareid, methname, *args, **kwargs):
         ll = self.landlords[shareid]
         return ll.callRemote(methname, *args, **kwargs)