From 95a2501e49ac4721826071d60234ca42faeec5ca Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 5 Jan 2021 18:22:34 +0100 Subject: [PATCH] Update the full hazelnuts table when adding a new potential neighbour --- squinnondation/messages.py | 5 +++-- squinnondation/squinnondation.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/squinnondation/messages.py b/squinnondation/messages.py index 531f3c9..faaa7ad 100644 --- a/squinnondation/messages.py +++ b/squinnondation/messages.py @@ -229,8 +229,9 @@ class NeighbourTLV(TLV): return if not (str(self.ip_address), self.port) in squirrel.activehazelnuts \ and not (str(self.ip_address), self.port) in squirrel.potentialhazelnuts: - squirrel.potentialhazelnuts[(str(self.ip_address), self.port)] = \ - squirrel.new_hazel(str(self.ip_address), self.port) + hazelnut = squirrel.new_hazel(str(self.ip_address), self.port) + hazelnut.potential = True + squirrel.update_hazelnut_table(hazelnut) # squirrel.add_system_message(f"New potential friend {self.ip_address}:{self.port}!") @staticmethod diff --git a/squinnondation/squinnondation.py b/squinnondation/squinnondation.py index be8f09d..2b93e9b 100644 --- a/squinnondation/squinnondation.py +++ b/squinnondation/squinnondation.py @@ -78,7 +78,8 @@ class Squinnondation: if instance.args.client_address and instance.args.client_port: hazelnut = Hazelnut(address=instance.args.client_address, port=instance.args.client_port) - squirrel.potentialhazelnuts[instance.args.client_address, instance.args.client_port] = hazelnut + hazelnut.potential = True + squirrel.update_hazelnut_table(hazelnut) htlv = HelloTLV().construct(8, squirrel) pkt = Packet().construct(htlv) squirrel.send_packet(hazelnut, pkt)