checker.py: minor simplifications
authorBrian Warner <warner@lothar.com>
Wed, 4 Apr 2012 19:05:31 +0000 (12:05 -0700)
committerBrian Warner <warner@lothar.com>
Wed, 4 Apr 2012 19:05:31 +0000 (12:05 -0700)
src/allmydata/immutable/checker.py

index ad7931b9a865885578771a5ad45052b6c20911d5..73ebc1ec18604a68bc18eef99ea29544fff6b9c4 100644 (file)
@@ -737,25 +737,26 @@ class Checker(log.PrefixingLogMixin):
         return d
 
     def _format_results(self, results):
-        cr = CheckResults(self._verifycap, self._verifycap.get_storage_index())
+        SI = self._verifycap.get_storage_index()
+        cr = CheckResults(self._verifycap, SI)
         d = {}
         d['count-shares-needed'] = self._verifycap.needed_shares
         d['count-shares-expected'] = self._verifycap.total_shares
 
         verifiedshares = dictutil.DictOfSets() # {sharenum: set(serverid)}
         servers = {} # {serverid: set(sharenums)}
-        corruptsharelocators = [] # (serverid, storageindex, sharenum)
-        incompatiblesharelocators = [] # (serverid, storageindex, sharenum)
-
-        for theseverifiedshares, thisserver, thesecorruptshares, theseincompatibleshares, thisresponded in results:
-            thisserverid = thisserver.get_serverid()
-            servers.setdefault(thisserverid, set()).update(theseverifiedshares)
-            for sharenum in theseverifiedshares:
-                verifiedshares.setdefault(sharenum, set()).add(thisserverid)
-            for sharenum in thesecorruptshares:
-                corruptsharelocators.append((thisserverid, self._verifycap.get_storage_index(), sharenum))
-            for sharenum in theseincompatibleshares:
-                incompatiblesharelocators.append((thisserverid, self._verifycap.get_storage_index(), sharenum))
+        corruptshare_locators = [] # (serverid, storageindex, sharenum)
+        incompatibleshare_locators = [] # (serverid, storageindex, sharenum)
+
+        for verified, server, corrupt, incompatible, responded in results:
+            server_id = server.get_serverid()
+            servers.setdefault(server_id, set()).update(verified)
+            for sharenum in verified:
+                verifiedshares.setdefault(sharenum, set()).add(server_id)
+            for sharenum in corrupt:
+                corruptshare_locators.append((server_id, SI, sharenum))
+            for sharenum in incompatible:
+                incompatibleshare_locators.append((server_id, SI, sharenum))
 
         d['count-shares-good'] = len(verifiedshares)
         d['count-good-share-hosts'] = len([s for s in servers.keys() if servers[s]])
@@ -783,10 +784,10 @@ class Checker(log.PrefixingLogMixin):
         d['sharemap'] = verifiedshares
         # no such thing as wrong shares of an immutable file
         d['count-wrong-shares'] = 0
-        d['list-corrupt-shares'] = corruptsharelocators
-        d['count-corrupt-shares'] = len(corruptsharelocators)
-        d['list-incompatible-shares'] = incompatiblesharelocators
-        d['count-incompatible-shares'] = len(incompatiblesharelocators)
+        d['list-corrupt-shares'] = corruptshare_locators
+        d['count-corrupt-shares'] = len(corruptshare_locators)
+        d['list-incompatible-shares'] = incompatibleshare_locators
+        d['count-incompatible-shares'] = len(incompatibleshare_locators)
 
 
         # The file needs rebalancing if the set of servers that have at least