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
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
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):
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])
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 = {
class FileUploader:
debug = False
+ ENCODERCLASS = codec.CRSEncoder
+
def __init__(self, peer):
self._peer = peer
# 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)