from twisted.internet import defer
import sha
from allmydata.util import idlib, mathutil
-from allmydata.interfaces import IEncoder, IDecoder
+from allmydata.interfaces import ICodecEncoder, ICodecDecoder
from allmydata.py_ecc import rs_code
def netstring(s):
return "%d:%s," % (len(s), s)
class ReplicatingEncoder(object):
- implements(IEncoder)
+ implements(ICodecEncoder)
ENCODER_TYPE = 0
def set_params(self, data_size, required_shares, total_shares):
return defer.succeed(shares)
class ReplicatingDecoder(object):
- implements(IDecoder)
+ implements(ICodecDecoder)
def set_serialized_params(self, params):
self.required_shares = int(params)
class PyRSEncoder(object):
+ implements(ICodecEncoder)
ENCODER_TYPE = 1
# we will break the data into vectors in which each element is a single
return defer.succeed(shares)
class PyRSDecoder(object):
+ implements(ICodecDecoder)
def set_serialized_params(self, params):
pieces = params.split(":")
# need more to move directories
-class IEncoder(Interface):
+class ICodecEncoder(Interface):
def set_params(data_size, required_shares, total_shares):
"""Set up the parameters of this encoder.
total_shares * get_share_size().
"""
-class IDecoder(Interface):
+class ICodecDecoder(Interface):
def set_serialized_params(params):
"""Set up the parameters of this encoder, from a string returned by
encoder.get_serialized_params()."""
"""Decode a partial list of shares into data.
'some_shares' must be a list of (sharenum, share) tuples, a subset of
- the shares returned by IEncoder.encode(). Each share must be of the
- same length. The share tuples may appear in any order, but of course
- each tuple must have a sharenum that correctly matches the associated
- share data string.
+ the shares returned by ICodecEncode.encode(). Each share must be of
+ the same length. The share tuples may appear in any order, but of
+ course each tuple must have a sharenum that correctly matches the
+ associated share data string.
This returns a Deferred which fires with a string. This string will
always have a length equal to the 'data_size' value passed into the
- original IEncoder.set_params() call.
+ original ICodecEncode.set_params() call.
The length of 'some_shares' must be equal or greater than the value
- of 'required_shares' passed into the original IEncoder.set_params()
- call.
+ of 'required_shares' passed into the original
+ ICodecEncode.set_params() call.
"""