]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
start developing Roster, track all active peers
authorBrian Warner <warner@lothar.com>
Fri, 1 Dec 2006 00:43:15 +0000 (17:43 -0700)
committerBrian Warner <warner@lothar.com>
Fri, 1 Dec 2006 00:43:15 +0000 (17:43 -0700)
allmydata/client.py
allmydata/queen.py

index bca3ad037851f11fa7c4eb6719f5102ea9123e92..c60042a18caa58a0621d416b47ed54dce3dc2732 100644 (file)
@@ -12,7 +12,7 @@ reactor.installResolver(BlockingResolver())
 class Storage(service.MultiService, Referenceable):
     pass
 
-class Client(service.MultiService):
+class Client(service.MultiService, Referenceable):
     CERTFILE = "client.pem"
     AUTHKEYSFILE = "authorized_keys"
 
@@ -63,7 +63,7 @@ class Client(service.MultiService):
         log.msg("connected to queen")
         self.queen = queen
         queen.notifyOnDisconnect(self._lost_queen)
-        queen.callRemote("hello", urls=self.urls)
+        queen.callRemote("hello", nodeid=self.tub.tubID, self=self, urls=self.urls)
 
     def _lost_queen(self):
         log.msg("lost connection to queen")
index a06f90b4208dbc505c99857c4fb0372baa278ad3..1c7158a0d59b0cf1f1d03478fe8103deb502f51f 100644 (file)
@@ -6,8 +6,19 @@ import os.path
 from allmydata.util.iputil import get_local_ip_for
 
 class Roster(service.MultiService, Referenceable):
-    def remote_hello(self, urls):
-        print "contact from %s" % urls
+    def __init__(self):
+        service.MultiService.__init__(self)
+        self.active_peers = {}
+
+    def remote_hello(self, nodeid, node, urls):
+        log.msg("contact from %s" % nodeid)
+        self.active_peers[nodeid] = urls
+        node.notifyOnDisconnect(self._lost_node, nodeid)
+
+    def _lost_node(self, nodeid):
+        log.msg("lost contact with %s" % nodeid)
+        del self.active_peers[nodeid]
+
 
 class Queen(service.MultiService):
     CERTFILE = "queen.pem"