From: Brian Warner Date: Tue, 8 Dec 2009 17:26:08 +0000 (-0800) Subject: mutable/servermap.py: stop reaching into private MutableFileNode attributes X-Git-Url: https://git.rkrishnan.org/junkers?a=commitdiff_plain;h=aa3caf812d3549c6a72907b32a8b05cab8b416fe;p=tahoe-lafs%2Ftahoe-lafs.git mutable/servermap.py: stop reaching into private MutableFileNode attributes --- diff --git a/src/allmydata/mutable/filenode.py b/src/allmydata/mutable/filenode.py index f8e12b5f..27eb4473 100644 --- a/src/allmydata/mutable/filenode.py +++ b/src/allmydata/mutable/filenode.py @@ -149,7 +149,8 @@ class MutableFileNode: self._privkey = privkey def _populate_encprivkey(self, encprivkey): self._encprivkey = encprivkey - + def _add_to_cache(self, verinfo, shnum, offset, data, timestamp): + self._cache.add(verinfo, shnum, offset, data, timestamp) def get_write_enabler(self, peerid): assert len(peerid) == 20 @@ -171,6 +172,8 @@ class MutableFileNode: return self._readkey def get_storage_index(self): return self._storage_index + def get_fingerprint(self): + return self._fingerprint def get_privkey(self): return self._privkey def get_encprivkey(self): diff --git a/src/allmydata/mutable/servermap.py b/src/allmydata/mutable/servermap.py index f0b4d352..740eb378 100644 --- a/src/allmydata/mutable/servermap.py +++ b/src/allmydata/mutable/servermap.py @@ -379,7 +379,7 @@ class ServermapUpdater: # we use unpack_prefix_and_signature, so we need 1k self._read_size = 1000 self._need_privkey = False - if mode == MODE_WRITE and not self._node._privkey: + if mode == MODE_WRITE and not self._node.get_privkey(): self._need_privkey = True # check+repair: repair requires the privkey, so if we didn't happen # to ask for it during the check, we'll have problems doing the @@ -595,7 +595,7 @@ class ServermapUpdater: verinfo = self._got_results_one_share(shnum, data, peerid, lp) last_verinfo = verinfo last_shnum = shnum - self._node._cache.add(verinfo, shnum, 0, data, now) + self._node._add_to_cache(verinfo, shnum, 0, data, now) except CorruptShareError, e: # log it and give the other shares a chance to be processed f = failure.Failure() @@ -657,7 +657,7 @@ class ServermapUpdater: if not self._node.get_pubkey(): fingerprint = hashutil.ssk_pubkey_fingerprint_hash(pubkey_s) assert len(fingerprint) == 32 - if fingerprint != self._node._fingerprint: + if fingerprint != self._node.get_fingerprint(): raise CorruptShareError(peerid, shnum, "pubkey doesn't match fingerprint") self._node._populate_pubkey(self._deserialize_pubkey(pubkey_s)) @@ -674,7 +674,7 @@ class ServermapUpdater: if verinfo not in self._valid_versions: # it's a new pair. Verify the signature. - valid = self._node._pubkey.verify(prefix, signature) + valid = self._node.get_pubkey().verify(prefix, signature) if not valid: raise CorruptShareError(peerid, shnum, "signature is invalid") diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index fc6dc37f..0431d4fa 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -714,7 +714,7 @@ class Servermap(unittest.TestCase, PublishMixin): d.addCallback(lambda res: ms(mode=MODE_WRITE)) d.addCallback(lambda sm: self.failUnlessOneRecoverable(sm, 10)) d.addCallback(lambda res: ms(mode=MODE_READ)) - # this more stops at k+epsilon, and epsilon=k, so 6 shares + # this mode stops at k+epsilon, and epsilon=k, so 6 shares d.addCallback(lambda sm: self.failUnlessOneRecoverable(sm, 6)) d.addCallback(lambda res: ms(mode=MODE_ANYTHING)) # this mode stops at 'k' shares