From 4662164ecee204261ff766feceaf2e465696889c Mon Sep 17 00:00:00 2001 From: Tom Goff Date: Wed, 12 Oct 2016 17:35:18 +0000 Subject: [PATCH] daemon: Use a set to store broker networks. --- daemon/core/broker.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/daemon/core/broker.py b/daemon/core/broker.py index 8b949241..723561dc 100644 --- a/daemon/core/broker.py +++ b/daemon/core/broker.py @@ -49,8 +49,8 @@ class CoreBroker(ConfigurableManager): # reference counts of nodes on servers self.nodecounts = { } self.bootcount = 0 - # list of node numbers that are link-layer nodes (networks) - self.nets = [] + # set of node numbers that are link-layer nodes (networks) + self.nets = set() # list of node numbers that are PhysicalNode nodes self.phys = [] # allows for other message handlers to process API messages (e.g. EMANE) @@ -98,7 +98,7 @@ class CoreBroker(ConfigurableManager): self.nodecounts.clear() self.bootcount = 0 self.nodemap_lock.release() - del self.nets[:] + self.nets.clear() del self.phys[:] while len(self.tunnels) > 0: (key, gt) = self.tunnels.popitem() @@ -463,8 +463,7 @@ class CoreBroker(ConfigurableManager): def addnet(self, nodenum): ''' Add a node number to the list of link-layer nodes. ''' - if nodenum not in self.nets: - self.nets.append(nodenum) + self.nets.add(nodenum) def addphys(self, nodenum): ''' Add a node number to the list of physical nodes.