]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable: always include ourselves in the querylist when Publishing, because 0.7.0...
authorBrian Warner <warner@allmydata.com>
Wed, 19 Dec 2007 07:06:53 +0000 (00:06 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 19 Dec 2007 07:06:53 +0000 (00:06 -0700)
src/allmydata/mutable.py
src/allmydata/test/test_mutable.py

index 49493255cc894e6f38ea2883d764fea68fe0ae04..65fe89b2c6027a4d4284f2744ca9d1de2acd06a8 100644 (file)
@@ -825,7 +825,12 @@ class Publish:
         self._encprivkey_shares = []
 
         EPSILON = total_shares / 2
-        partial_peerlist = islice(peerlist, total_shares + EPSILON)
+        #partial_peerlist = islice(peerlist, total_shares + EPSILON)
+        partial_peerlist = peerlist[:total_shares+EPSILON]
+
+        # make sure our local server is in the list
+        partial_peerlist = self._add_ourselves(partial_peerlist, peerlist)
+
         peer_storage_servers = {}
         dl = []
         for (permutedid, peerid, conn) in partial_peerlist:
@@ -840,9 +845,29 @@ class Publish:
                       total_shares, reachable_peers,
                       current_share_peers, peer_storage_servers)
         # TODO: add an errback to, probably to ignore that peer
+        # TODO: if we can't get a privkey from these servers, consider
+        # looking farther afield. Make sure we include ourselves in the
+        # initial list, because of the 0.7.0 behavior that causes us to
+        # create our initial directory before we've connected to anyone
+        # but ourselves.
         return d
 
+    def _add_ourselves(self, partial_peerlist, peerlist):
+        my_peerid = self._node._client.nodeid
+        for (permutedid, peerid, conn) in partial_peerlist:
+            if peerid == my_peerid:
+                # we're already in there
+                return partial_peerlist
+        for (permutedid, peerid, conn) in peerlist:
+            if peerid == self._node._client.nodeid:
+                # found it
+                partial_peerlist.append( (permutedid, peerid, conn) )
+                return partial_peerlist
+        self.log("WEIRD: we aren't in our own peerlist??")
+        return partial_peerlist
+
     def _do_query(self, conn, peerid, peer_storage_servers, storage_index):
+        self.log("querying %s" % idlib.shortnodeid_b2a(peerid))
         d = conn.callRemote("get_service", "storageserver")
         def _got_storageserver(ss):
             peer_storage_servers[peerid] = ss
index 43eb1f9368f55b0dfa1713802b2cbc6300ee16a9..f42cd3f5a2e1f783a1aecef061f29364577fe6c1 100644 (file)
@@ -79,6 +79,8 @@ class FakeClient:
         self._peerids = [tagged_hash("peerid", "%d" % i)[:20]
                          for i in range(self._num_peers)]
         self.introducer_client = FakeIntroducerClient()
+        self.nodeid = "fakenodeid"
+
     def log(self, msg, **kw):
         return log.msg(msg, **kw)