switch to pyfec
authorZooko O'Whielacronx <zooko@zooko.com>
Wed, 28 Mar 2007 07:05:16 +0000 (00:05 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Wed, 28 Mar 2007 07:05:16 +0000 (00:05 -0700)
roadmap.txt
src/allmydata/codec.py
src/allmydata/upload.py

index 07112db4ed80004a5d7282f1aab3be5b9efc7aec..ab8c0329f72997f13ca114bca488fe67aa61f904 100644 (file)
@@ -15,7 +15,8 @@ File Encoding: Brian
 Share Encoding: Zooko
 *v1: fake it (replication)
 *v2: PyRS
- v3: C-based Reed-Solomon
+*v2.5: ICodec-based codecs, but still using replication
+*v3: C-based Reed-Solomon
 
 Peer selection:
 *v1: permuted peer list, consistent hash
index 910014f94a58c6609059ec70dd5c5e43530350cc..cbf9a51c40b8470b3c29744a963694ace5b2a3f2 100644 (file)
@@ -121,7 +121,7 @@ class Decoder(object):
 
 class CRSEncoder(object):
     implements(ICodecEncoder)
-    ENCODER_TYPE = 2
+    ENCODER_TYPE = "crs"
 
     def set_params(self, data_size, required_shares, max_shares):
         assert required_shares <= max_shares
@@ -136,7 +136,7 @@ class CRSEncoder(object):
         return self.ENCODER_TYPE
 
     def get_serialized_params(self):
-        return "%d:%d:%d" % (self.data_size, self.required_shares,
+        return "%d-%d-%d" % (self.data_size, self.required_shares,
                              self.max_shares)
 
     def get_share_size(self):
@@ -158,7 +158,7 @@ class CRSDecoder(object):
     implements(ICodecDecoder)
 
     def set_serialized_params(self, params):
-        pieces = params.split(":")
+        pieces = params.split("-")
         self.data_size = int(pieces[0])
         self.required_shares = int(pieces[1])
         self.max_shares = int(pieces[2])
@@ -180,7 +180,7 @@ class CRSDecoder(object):
     def decode(self, some_shares, their_shareids):
         precondition(len(some_shares) == len(their_shareids), len(some_shares), len(their_shareids))
         precondition(len(some_shares) == self.required_shares, len(some_shares), self.required_shares)
-        return defer.succeed(self.decoder.decode(some_shares, their_shareids))
+        return defer.succeed(self.decoder.decode(some_shares, [int(s) for s in their_shareids]))
 
 
 all_encoders = {
index 234d6fee30c8ef3562192b5a918cb86213fa84de..0fdf309dad3dc832bc3c38d31987d0464f657cee 100644 (file)
@@ -29,6 +29,8 @@ class TooFullError(Exception):
 
 class FileUploader:
     debug = False
+    ENCODERCLASS = codec.CRSEncoder
+
 
     def __init__(self, peer):
         self._peer = peer
@@ -68,7 +70,7 @@ class FileUploader:
         # create the encoder, so we can know how large the shares will be
         total_shares = self.max_shares
         needed_shares = self.min_shares
-        self._encoder = codec.ReplicatingEncoder()
+        self._encoder = self.ENCODERCLASS()
         self._codec_name = self._encoder.get_encoder_type()
         self._needed_shares = needed_shares
         paddedsize = self._size + mathutil.pad_size(self._size, needed_shares)