class MutableFileNode:
implements(IMutableFileNode, ICheckable)
SIGNATURE_KEY_SIZE = 2048
- DEFAULT_ENCODING = (3, 10)
checker_class = MutableChecker
check_and_repairer_class = MutableCheckAndRepairer
# we keep track of the last encoding parameters that we use. These
# are updated upon retrieve, and used by publish. If we publish
# without ever reading (i.e. overwrite()), then we use these values.
- (self._required_shares, self._total_shares) = self.DEFAULT_ENCODING
+ defaults = client.get_encoding_parameters()
+ self._required_shares = defaults["k"]
+ self._total_shares = defaults["n"]
self._sharemap = {} # known shares, shnum-to-[nodeids]
self._cache = ResponseCache()
self._uri = WriteableSSKFileURI(self._writekey, self._fingerprint)
self._readkey = self._uri.readkey
self._storage_index = self._uri.storage_index
- self._required_shares, self._total_shares = self.DEFAULT_ENCODING
def _generate_pubprivkeys(self, keypair_generator):
if keypair_generator:
pass
class FakeClient:
- # just enough to let the node acquire a downloader (which it won't use)
+ # just enough to let the node acquire a downloader (which it won't use),
+ # and to get default encoding parameters
def getServiceNamed(self, name):
return None
+ def get_encoding_parameters(self):
+ return {"k": 3, "n": 10}
class Node(unittest.TestCase):
def test_chk_filenode(self):
return d
def test_mutable_filenode(self):
- client = None
+ client = FakeClient()
wk = "\x00"*16
fp = "\x00"*32
rk = hashutil.ssk_readkey_hash(wk)
for peerid in self._peerids])
self.nodeid = "fakenodeid"
+ def get_encoding_parameters(self):
+ return {"k": 3, "n": 10}
+
def log(self, msg, **kw):
return log.msg(msg, **kw)