]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable/servermap.py: stop reaching into private MutableFileNode attributes
authorBrian Warner <warner@lothar.com>
Tue, 8 Dec 2009 17:26:08 +0000 (09:26 -0800)
committerBrian Warner <warner@lothar.com>
Tue, 8 Dec 2009 17:26:08 +0000 (09:26 -0800)
src/allmydata/mutable/filenode.py
src/allmydata/mutable/servermap.py
src/allmydata/test/test_mutable.py

index f8e12b5fc088e67bde6b7ce0f3f405bcc49df686..27eb4473e66491759297b9962341903ec562e1fb 100644 (file)
@@ -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):
index f0b4d3520ee6679591f89c335c75b4845e683cf7..740eb378a36336456857d274b3d5cc9741ea9217 100644 (file)
@@ -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")
 
index fc6dc37f00810c6b15b1b9fcd8a2f625839ba877..0431d4fa43d6f5de9f6a555f58b6d646068d3a81 100644 (file)
@@ -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