From: Zooko O'Whielacronx Date: Wed, 28 Mar 2007 07:05:16 +0000 (-0700) Subject: switch to pyfec X-Git-Url: https://git.rkrishnan.org/vdrive/%22file:/frontends/%22doc.html/reliability?a=commitdiff_plain;h=81c8cb6d6a18f3115333b51c5b7de6d8caa760dd;p=tahoe-lafs%2Ftahoe-lafs.git switch to pyfec --- diff --git a/roadmap.txt b/roadmap.txt index 07112db4..ab8c0329 100644 --- a/roadmap.txt +++ b/roadmap.txt @@ -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 diff --git a/src/allmydata/codec.py b/src/allmydata/codec.py index 910014f9..cbf9a51c 100644 --- a/src/allmydata/codec.py +++ b/src/allmydata/codec.py @@ -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 = { diff --git a/src/allmydata/upload.py b/src/allmydata/upload.py index 234d6fee..0fdf309d 100644 --- a/src/allmydata/upload.py +++ b/src/allmydata/upload.py @@ -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)