def announce(self): if not self._bt_port: return [], False nodes_to_announce = self._lookup_queue.get_closest_responded_qnodes() announce_to_myself = False #TODO: is is worth it to announce to self? The problem is that I don't #know my own IP number. Maybe if 127.0.0.1 translates into "I (the #node returning 127.0.0.1) am in the swarm". ''' if len(nodes_to_announce) < ANNOUNCE_REDUNDANCY: announce_to_myself = True elif (self._my_id.log_distance(self.info_hash) < nodes_to_announce[ANNOUNCE_REDUNDANCY-1].id.log_distance( self.info_hash)): nodes_to_announce = nodes_to_announce[:-1] announce_to_myself = True ''' queries_to_send = [] for qnode in nodes_to_announce: logger.debug('announcing to %r' % qnode.node) query = message.OutgoingAnnouncePeerQuery(qnode.node, self._my_id, self.info_hash, self._bt_port, qnode.token) queries_to_send.append(query) return queries_to_send, announce_to_myself
def announce(self): if not self._bt_port: return ([], False) nodes_to_announce = self._lookup_queue.get_closest_responded_qnodes() announce_to_myself = False queries_to_send = [] for qnode in nodes_to_announce: logger.debug('announcing to %r' % qnode.node) msg = message.OutgoingAnnouncePeerQuery(self._my_id, self._info_hash, self._bt_port, qnode.token) queries_to_send.append(Query(msg, qnode.node, self)) return (queries_to_send, announce_to_myself)