mutable: respect the new tahoe.cfg 'shares.needed' and 'shares.total' settings
This commit is contained in:
parent
82fe7ba360
commit
6f6556da22
|
@ -50,7 +50,6 @@ class BackoffAgent:
|
||||||
class MutableFileNode:
|
class MutableFileNode:
|
||||||
implements(IMutableFileNode, ICheckable)
|
implements(IMutableFileNode, ICheckable)
|
||||||
SIGNATURE_KEY_SIZE = 2048
|
SIGNATURE_KEY_SIZE = 2048
|
||||||
DEFAULT_ENCODING = (3, 10)
|
|
||||||
checker_class = MutableChecker
|
checker_class = MutableChecker
|
||||||
check_and_repairer_class = MutableCheckAndRepairer
|
check_and_repairer_class = MutableCheckAndRepairer
|
||||||
|
|
||||||
|
@ -61,7 +60,9 @@ class MutableFileNode:
|
||||||
# we keep track of the last encoding parameters that we use. These
|
# we keep track of the last encoding parameters that we use. These
|
||||||
# are updated upon retrieve, and used by publish. If we publish
|
# are updated upon retrieve, and used by publish. If we publish
|
||||||
# without ever reading (i.e. overwrite()), then we use these values.
|
# 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._sharemap = {} # known shares, shnum-to-[nodeids]
|
||||||
self._cache = ResponseCache()
|
self._cache = ResponseCache()
|
||||||
|
|
||||||
|
@ -121,7 +122,6 @@ class MutableFileNode:
|
||||||
self._uri = WriteableSSKFileURI(self._writekey, self._fingerprint)
|
self._uri = WriteableSSKFileURI(self._writekey, self._fingerprint)
|
||||||
self._readkey = self._uri.readkey
|
self._readkey = self._uri.readkey
|
||||||
self._storage_index = self._uri.storage_index
|
self._storage_index = self._uri.storage_index
|
||||||
self._required_shares, self._total_shares = self.DEFAULT_ENCODING
|
|
||||||
|
|
||||||
def _generate_pubprivkeys(self, keypair_generator):
|
def _generate_pubprivkeys(self, keypair_generator):
|
||||||
if keypair_generator:
|
if keypair_generator:
|
||||||
|
|
|
@ -11,9 +11,12 @@ class NotANode:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class FakeClient:
|
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):
|
def getServiceNamed(self, name):
|
||||||
return None
|
return None
|
||||||
|
def get_encoding_parameters(self):
|
||||||
|
return {"k": 3, "n": 10}
|
||||||
|
|
||||||
class Node(unittest.TestCase):
|
class Node(unittest.TestCase):
|
||||||
def test_chk_filenode(self):
|
def test_chk_filenode(self):
|
||||||
|
@ -81,7 +84,7 @@ class Node(unittest.TestCase):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def test_mutable_filenode(self):
|
def test_mutable_filenode(self):
|
||||||
client = None
|
client = FakeClient()
|
||||||
wk = "\x00"*16
|
wk = "\x00"*16
|
||||||
fp = "\x00"*32
|
fp = "\x00"*32
|
||||||
rk = hashutil.ssk_readkey_hash(wk)
|
rk = hashutil.ssk_readkey_hash(wk)
|
||||||
|
|
|
@ -177,6 +177,9 @@ class FakeClient:
|
||||||
for peerid in self._peerids])
|
for peerid in self._peerids])
|
||||||
self.nodeid = "fakenodeid"
|
self.nodeid = "fakenodeid"
|
||||||
|
|
||||||
|
def get_encoding_parameters(self):
|
||||||
|
return {"k": 3, "n": 10}
|
||||||
|
|
||||||
def log(self, msg, **kw):
|
def log(self, msg, **kw):
|
||||||
return log.msg(msg, **kw)
|
return log.msg(msg, **kw)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue