change IEncoder to ICodecEncoder, to match the previous change

This commit is contained in:
Brian Warner 2007-01-11 20:57:14 -07:00
parent 417c17755b
commit e29032bc36
2 changed files with 14 additions and 12 deletions

View File

@ -4,14 +4,14 @@ from zope.interface import implements
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):
@ -33,7 +33,7 @@ class ReplicatingEncoder(object):
return defer.succeed(shares)
class ReplicatingDecoder(object):
implements(IDecoder)
implements(ICodecDecoder)
def set_serialized_params(self, params):
self.required_shares = int(params)
@ -89,6 +89,7 @@ class Decoder(object):
class PyRSEncoder(object):
implements(ICodecEncoder)
ENCODER_TYPE = 1
# we will break the data into vectors in which each element is a single
@ -163,6 +164,7 @@ class PyRSEncoder(object):
return defer.succeed(shares)
class PyRSDecoder(object):
implements(ICodecDecoder)
def set_serialized_params(self, params):
pieces = params.split(":")

View File

@ -71,7 +71,7 @@ class RIMutableDirectoryNode(RemoteInterface):
# 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.
@ -123,7 +123,7 @@ class IEncoder(Interface):
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()."""
@ -132,16 +132,16 @@ class IDecoder(Interface):
"""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.
"""