]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable: respect the new tahoe.cfg 'shares.needed' and 'shares.total' settings
authorBrian Warner <warner@allmydata.com>
Wed, 19 Nov 2008 21:05:01 +0000 (14:05 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 19 Nov 2008 21:05:01 +0000 (14:05 -0700)
src/allmydata/mutable/node.py
src/allmydata/test/test_filenode.py
src/allmydata/test/test_mutable.py

index 8ab2eacf47e29d57e9637c2dbf66d5f643220d97..98942a66de1b22361f632b0f953419b8ffe8af8a 100644 (file)
@@ -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:
index ecf7408947f87d8e1ffbdb2b531c806e473ad6fa..025e76e69aac97ebc4decc911e8343d7f20d919f 100644 (file)
@@ -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)
index 63983de59d7d5a5eb1ff6ea11d2a614b12c1a7d9..f19eeb04593a48bd8295bb300f35fdbe8c787995 100644 (file)
@@ -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)