def add_friend(self, addr, name): if addr in self.enemies: self.enemies.remove(addr) if addr not in self.friends: self.friends[addr] = name if addr not in self.peers: self.peers[addr] = Peer.from_addr(self, addr, name) return name, self.peers[addr]
def try_peers(self): 'Attempt to connect to all friends' self.peers = {} for addr, name in self.friends.items(): self.peers[addr] = Peer.from_addr(self, addr, name)