mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 18:56:28 +00:00
switch to pyfec
This commit is contained in:
parent
4e86a6df76
commit
81c8cb6d6a
@ -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
|
||||
|
@ -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 = {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user