From 346e38674b5cfc3cc86727027754370902d0a560 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Fri, 22 May 2015 15:26:17 +0900 Subject: [PATCH] Absorb add_interface and remove_interface They are now only called from the same place; it's simpler and clearer to put them inline. --- lib/network.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/network.py b/lib/network.py index 89561d9f7..6b45d00a1 100644 --- a/lib/network.py +++ b/lib/network.py @@ -402,14 +402,6 @@ class Network(util.DaemonThread): self.recent_servers = self.recent_servers[0:20] self.save_recent_servers() - def add_interface(self, i): - self.interfaces[i.server] = i - self.notify('interfaces') - - def remove_interface(self, i): - self.interfaces.pop(i.server) - self.notify('interfaces') - def new_blockchain_height(self, blockchain_height, i): if self.is_connected(): if self.server_is_lagging(): @@ -419,23 +411,25 @@ class Network(util.DaemonThread): self.notify('updated') def process_if_notification(self, i): + '''Handle interface addition and removal through notifications''' if i.server in self.pending_servers: self.pending_servers.remove(i.server) if i.is_connected(): - self.add_interface(i) + self.interfaces[i.server] = i self.add_recent_server(i) i.send_request({'method':'blockchain.headers.subscribe','params':[]}) if i.server == self.default_server: self.switch_to_interface(i.server) else: - if i.server in self.interfaces: - self.remove_interface(i) - if i.server in self.heights: - self.heights.pop(i.server) + self.interfaces.pop(i.server, None) + self.heights.pop(i.server, None) if i == self.interface: self.set_status('disconnected') self.disconnected_servers.add(i.server) + # Our set of interfaces changed + self.notify('interfaces') + def process_response(self, i, response): # the id comes from the daemon or the network proxy