From: Brian Warner Date: Wed, 19 Nov 2008 21:05:01 +0000 (-0700) Subject: mutable: respect the new tahoe.cfg 'shares.needed' and 'shares.total' settings X-Git-Url: https://git.rkrishnan.org/vdrive/global?a=commitdiff_plain;h=6f6556da226d7778c7eaaed8bedbdb8ce4e05fb2;p=tahoe-lafs%2Ftahoe-lafs.git mutable: respect the new tahoe.cfg 'shares.needed' and 'shares.total' settings --- diff --git a/src/allmydata/mutable/node.py b/src/allmydata/mutable/node.py index 8ab2eacf..98942a66 100644 --- a/src/allmydata/mutable/node.py +++ b/src/allmydata/mutable/node.py @@ -50,7 +50,6 @@ class BackoffAgent: class MutableFileNode: implements(IMutableFileNode, ICheckable) SIGNATURE_KEY_SIZE = 2048 - DEFAULT_ENCODING = (3, 10) checker_class = MutableChecker check_and_repairer_class = MutableCheckAndRepairer @@ -61,7 +60,9 @@ class MutableFileNode: # 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() @@ -121,7 +122,6 @@ class MutableFileNode: 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: diff --git a/src/allmydata/test/test_filenode.py b/src/allmydata/test/test_filenode.py index ecf74089..025e76e6 100644 --- a/src/allmydata/test/test_filenode.py +++ b/src/allmydata/test/test_filenode.py @@ -11,9 +11,12 @@ class NotANode: 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): @@ -81,7 +84,7 @@ class Node(unittest.TestCase): return d def test_mutable_filenode(self): - client = None + client = FakeClient() wk = "\x00"*16 fp = "\x00"*32 rk = hashutil.ssk_readkey_hash(wk) diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 63983de5..f19eeb04 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -177,6 +177,9 @@ class FakeClient: 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)