diff --git a/src/decentralizepy/communication/TCPRandomWalkRouting.py b/src/decentralizepy/communication/TCPRandomWalkRouting.py index 7aeaf58408b242e196235d6dc54b2ebea12d1e40..ce1c7e8ff9a7565c4327b6dc5275f0e08ce2c8ea 100644 --- a/src/decentralizepy/communication/TCPRandomWalkRouting.py +++ b/src/decentralizepy/communication/TCPRandomWalkRouting.py @@ -414,7 +414,7 @@ class TCPRandomWalkRoutingInternal(TCPRandomWalkBase): if type(data) == tuple and data[0] == HELLO: logging.debug("Received {} from {}".format(HELLO, src)) if src in self.current_neighbors: - if data[1] != "fw at neighbor": + if data[1] != "fw at neighbor": # TODO: this is wrong logging.critical( "{} wants to connect when already connected!".format(HELLO, src) ) @@ -499,8 +499,8 @@ class TCPRandomWalkRoutingInternal(TCPRandomWalkBase): "RW message is delivered here due to no new neighbors being available: %s", str(data["visited"]), ) - "fw at neighbor" - self.connect(new_data["routing_info"]) + # TODO: check if not already a neighbor + #self.connect(new_data["routing_info"]) return else: logging.info( @@ -632,18 +632,10 @@ class TCPRandomWalkRoutingInternal(TCPRandomWalkBase): ) # True -> we initiated logging.info(f"Added {sender} to future neighbors") del self.outgoing_request[sender] # cannot advance until this is empty - elif round < self.current_round: # we are ahead - # TODO: might cause a blocking behaviour, if both start a connection to each other - if self.current_data != None: - self.send( - sender, self.current_data - ) # messaging is tcp based --> always arrives after hello - self.current_neighbors.add(sender) - logging.info(f"Added {sender} to current neighbors") - del self.outgoing_request[sender] + elif round == self.current_round - 1: # we are ahead # should never arrive, as other round should advance and then send to us with current round - logging.info(f"Received a hello from {sender} with {round}") - # raise RuntimeError(f"Received a hello from {sender} with {round}") + logging.critical(f"Received a hello from {sender} with {round}") + raise RuntimeError(f"Received a hello from {sender} with {round}") else: logging.critical(f"Received a hello from {sender} with {round}") raise RuntimeError(f"Received a hello from {sender} with {round}")