continue
self.log("adding peer %s" % idlib.b2a(nodeid))
if nodeid in self.all_peers:
- log.msg("weird, I already had an entry for them")
+ self.log("weird, I already had an entry for them")
+ return
self.all_peers.add(nodeid)
if nodeid not in self.connections:
d = self.tub.getReference(pburl)
def get_remote_service(self, nodeid, servicename):
if nodeid not in self.connections:
return defer.fail(IndexError("no connection to that peer"))
- d = self.connections[nodeid].callRemote("get_service",
- name=servicename)
+ peer = self.connections[nodeid]
+ d = peer.callRemote("get_service", name=servicename)
return d
self.connections = {}
def remote_hello(self, nodeid, node, pburl):
- log.msg("contact from %s" % idlib.b2a(nodeid))
- eventually(self._educate_the_new_peer, node)
- eventually(self._announce_new_peer, nodeid, pburl)
+ log.msg("roster: contact from %s" % idlib.b2a(nodeid))
+ eventually(self._educate_the_new_peer,
+ node, list(self.phonebook.items()))
+ eventually(self._announce_new_peer,
+ nodeid, pburl, list(self.connections.values()))
self.phonebook[nodeid] = pburl
self.connections[nodeid] = node
node.notifyOnDisconnect(self._lost_node, nodeid)
- def _educate_the_new_peer(self, node):
- node.callRemote("add_peers", new_peers=list(self.phonebook.items()))
+ def _educate_the_new_peer(self, node, new_peers):
+ node.callRemote("add_peers", new_peers=new_peers)
- def _announce_new_peer(self, new_nodeid, new_node_pburl):
- for targetnode in self.connections.values():
+ def _announce_new_peer(self, new_nodeid, new_node_pburl, peers):
+ for targetnode in peers:
targetnode.callRemote("add_peers",
new_peers=[(new_nodeid, new_node_pburl)])