mutable: respect the new tahoe.cfg 'shares.needed' and 'shares.total' settings

This commit is contained in:
Brian Warner 2008-11-19 14:05:01 -07:00
parent 82fe7ba360
commit 6f6556da22
3 changed files with 11 additions and 5 deletions

View 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:

View 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)

View 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)