]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
introducer: add get_nickname_for_peerid
authorBrian Warner <warner@allmydata.com>
Sat, 6 Sep 2008 05:07:00 +0000 (22:07 -0700)
committerBrian Warner <warner@allmydata.com>
Sat, 6 Sep 2008 05:07:00 +0000 (22:07 -0700)
src/allmydata/client.py
src/allmydata/introducer/client.py
src/allmydata/introducer/old.py
src/allmydata/test/test_introducer.py

index 87f498334438f1503ffba5f7e14002029b83a45a..850af9fa5947e140ba32f30c99bf41f9f9f23ee3 100644 (file)
@@ -256,6 +256,8 @@ class Client(node.Node, testutil.PollMixin):
 
     def get_all_peerids(self):
         return self.introducer_client.get_all_peerids()
+    def get_nickname_for_peerid(self, peerid):
+        return self.introducer_client.get_nickname_for_peerid(peerid)
 
     def get_permuted_peers(self, service_name, key):
         """
index bc7d5fd3fe3ef19b976d0923b7042d3080ef15fb..4b9484f9854409b2877cbf9cd77f9a189c1831df 100644 (file)
@@ -244,6 +244,14 @@ class IntroducerClient(service.Service, Referenceable):
                           for (peerid, service_name, rref)
                           in self._connections])
 
+    def get_nickname_for_peerid(self, peerid):
+        for k in self._connectors:
+            (peerid0, svcname0) = k
+            if peerid0 == peerid:
+                rsc = self._connectors[k]
+                return rsc.nickname
+        return None
+
     def get_all_connections_for(self, service_name):
         return frozenset([c
                           for c in self._connections
index 7aaa345c0bdafa31d2c12792665c4c455037dcb8..d3440dac8a2f1e88741c970915059fac80e5d8b9 100644 (file)
@@ -247,6 +247,14 @@ class IntroducerClient_V1(service.Service, Referenceable):
                           for (peerid, service_name, rref)
                           in self._connections])
 
+    def get_nickname_for_peerid(self, peerid):
+        for k in self._connectors:
+            (peerid0, svcname0) = k
+            if peerid0 == peerid:
+                rsc = self._connectors[k]
+                return rsc.nickname
+        return None
+
     def get_all_connections_for(self, service_name):
         return frozenset([c
                           for c in self._connections
index a891fbfcad3f01b92d6c3a013eb259e08b4f2c81..08d52915b7357198a7be4842f7514cce02d62521 100644 (file)
@@ -152,6 +152,9 @@ class SystemTest(SystemTestMixin, unittest.TestCase):
                 self.failUnlessEqual(len(c.get_all_peerids()), NUMCLIENTS)
                 self.failUnlessEqual(len(c.get_all_connections_for("storage")),
                                      NUMCLIENTS)
+                nodeid0 = b32decode(tubs[clients[0]].tubID.upper())
+                self.failUnlessEqual(c.get_nickname_for_peerid(nodeid0),
+                                     "nickname-0")
         d.addCallback(_check1)
 
         origin_c = clients[0]