Skip to content
Snippets Groups Projects
Commit 651db87b authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

optimize code, need to test

parent 44fbab4f
Branches self-stabilizing-algorithm
No related tags found
No related merge requests found
......@@ -283,8 +283,8 @@ def update_neighbor_info():
while True:
try:
if not update_neighbor_info_queue.empty():
is_notify_neighbor = False
if not update_neighbor_info_queue.empty():
while not update_neighbor_info_queue.empty():
neighbor = update_neighbor_info_queue.get()
......@@ -305,20 +305,8 @@ def update_neighbor_info():
reset_me()
is_notify_neighbor = True
is_apply_rule = apply_rule()
if is_apply_rule or is_notify_neighbor:
send_node_info()
for neighbor in map_neighbor.values():
message = struct.pack('!IIIIIII', magic_hdr, Cmd.SHARE_INFO, node.myid, node.degree, node.color, node.color_id, node.pointer)
send_packet(neighbor.iface, neighbor.mac, message)
node.converge_time = time.time()
print_my_info()
elif apply_rule():
if apply_rule() or is_notify_neighbor:
send_node_info()
print("My current state: ", node.state)
for neighbor in map_neighbor.values():
message = struct.pack('!IIIIIII', magic_hdr, Cmd.SHARE_INFO, node.myid, node.degree, node.color, node.color_id, node.pointer)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment