From: Brian Warner Date: Sat, 6 Sep 2008 05:07:00 +0000 (-0700) Subject: introducer: add get_nickname_for_peerid X-Git-Url: https://git.rkrishnan.org/tahoe_css?a=commitdiff_plain;h=e2c484a7611b22fb5c22b37d4eec7b708695c167;p=tahoe-lafs%2Ftahoe-lafs.git introducer: add get_nickname_for_peerid --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 87f49833..850af9fa 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -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): """ diff --git a/src/allmydata/introducer/client.py b/src/allmydata/introducer/client.py index bc7d5fd3..4b9484f9 100644 --- a/src/allmydata/introducer/client.py +++ b/src/allmydata/introducer/client.py @@ -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 diff --git a/src/allmydata/introducer/old.py b/src/allmydata/introducer/old.py index 7aaa345c..d3440dac 100644 --- a/src/allmydata/introducer/old.py +++ b/src/allmydata/introducer/old.py @@ -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 diff --git a/src/allmydata/test/test_introducer.py b/src/allmydata/test/test_introducer.py index a891fbfc..08d52915 100644 --- a/src/allmydata/test/test_introducer.py +++ b/src/allmydata/test/test_introducer.py @@ -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]