mutable/retrieve.py: stop reaching into private MutableFileNode attributes
authorBrian Warner <warner@lothar.com>
Tue, 8 Dec 2009 17:29:21 +0000 (09:29 -0800)
committerBrian Warner <warner@lothar.com>
Tue, 8 Dec 2009 17:29:21 +0000 (09:29 -0800)
src/allmydata/mutable/filenode.py
src/allmydata/mutable/retrieve.py

index 27eb4473e66491759297b9962341903ec562e1fb..5e66ad368430fc9c43b7ed9fa9462ce1a34c6d6a 100644 (file)
@@ -151,6 +151,8 @@ class MutableFileNode:
         self._encprivkey = encprivkey
     def _add_to_cache(self, verinfo, shnum, offset, data, timestamp):
         self._cache.add(verinfo, shnum, offset, data, timestamp)
+    def _read_from_cache(self, verinfo, shnum, offset, length):
+        return self._cache.read(verinfo, shnum, offset, length)
 
     def get_write_enabler(self, peerid):
         assert len(peerid) == 20
index c90d1ce53b2c10c1c356bf9d5ef9cc072d3ad9a4..9165ebd1a9ee5d2d9431bad2c517135eca84d1cd 100644 (file)
@@ -83,9 +83,9 @@ class Retrieve:
 
     def __init__(self, filenode, servermap, verinfo, fetch_privkey=False):
         self._node = filenode
-        assert self._node._pubkey
+        assert self._node.get_pubkey()
         self._storage_index = filenode.get_storage_index()
-        assert self._node._readkey
+        assert self._node.get_readkey()
         self._last_failure = None
         prefix = si_b2a(self._storage_index)[:5]
         self._log_number = log.msg("Retrieve(%s): starting" % prefix)
@@ -95,13 +95,13 @@ class Retrieve:
         self._bad_shares = set()
 
         self.servermap = servermap
-        assert self._node._pubkey
+        assert self._node.get_pubkey()
         self.verinfo = verinfo
         # during repair, we may be called upon to grab the private key, since
         # it wasn't picked up during a verify=False checker run, and we'll
         # need it for repair to generate the a new version.
         self._need_privkey = fetch_privkey
-        if self._node._privkey:
+        if self._node.get_privkey():
             self._need_privkey = False
 
         self._status = RetrieveStatus()
@@ -198,8 +198,8 @@ class Retrieve:
         got_from_cache = False
         datavs = []
         for (offset, length) in readv:
-            (data, timestamp) = self._node._cache.read(self.verinfo, shnum,
-                                                       offset, length)
+            (data, timestamp) = self._node._read_from_cache(self.verinfo, shnum,
+                                                            offset, length)
             if data is not None:
                 datavs.append(data)
         if len(datavs) == len(readv):
@@ -395,7 +395,7 @@ class Retrieve:
         self._status.timings["fetch"] = elapsed
 
         d = defer.maybeDeferred(self._decode)
-        d.addCallback(self._decrypt, IV, self._node._readkey)
+        d.addCallback(self._decrypt, IV, self._node.get_readkey())
         d.addBoth(self._done)
         return d # purely for test convenience