Browse Source

Put getting of auto_cycle into one place.

Default to False consistently; this may change the behaviour of
network.py's get_parameters().
283
Neil Booth 10 years ago
parent
commit
4f6d2f3d32
  1. 1
      gui/text.py
  2. 12
      lib/network.py

1
gui/text.py

@ -352,7 +352,6 @@ class ElectrumGui:
def network_dialog(self): def network_dialog(self):
if not self.network: return if not self.network: return
auto_connect = self.network.config.get('auto_cycle')
host, port, protocol, proxy_config, auto_connect = self.network.get_parameters() host, port, protocol, proxy_config, auto_connect = self.network.get_parameters()
srv = 'auto-connect' if auto_connect else self.network.default_server srv = 'auto-connect' if auto_connect else self.network.default_server

12
lib/network.py

@ -249,8 +249,10 @@ class Network(util.DaemonThread):
def get_parameters(self): def get_parameters(self):
host, port, protocol = deserialize_server(self.default_server) host, port, protocol = deserialize_server(self.default_server)
auto_connect = self.config.get('auto_cycle', True) return host, port, protocol, self.proxy, self.auto_connect()
return host, port, protocol, self.proxy, auto_connect
def auto_connect(self):
return self.config.get('auto_cycle', False)
def get_interfaces(self): def get_interfaces(self):
return self.interfaces.keys() return self.interfaces.keys()
@ -382,7 +384,7 @@ class Network(util.DaemonThread):
if self.is_connected(): if self.is_connected():
if self.server_is_lagging(): if self.server_is_lagging():
self.print_error("Server is lagging", blockchain_height, self.get_server_height()) self.print_error("Server is lagging", blockchain_height, self.get_server_height())
if self.config.get('auto_cycle'): if self.auto_connect():
self.set_server(i.server) self.set_server(i.server)
self.notify('updated') self.notify('updated')
@ -481,7 +483,7 @@ class Network(util.DaemonThread):
self.nodes_retry_time = now self.nodes_retry_time = now
# main interface # main interface
if not self.is_connected(): if not self.is_connected():
if self.config.get('auto_cycle'): if self.auto_connect():
self.switch_to_random_interface() self.switch_to_random_interface()
else: else:
if self.default_server in self.disconnected_servers: if self.default_server in self.disconnected_servers:
@ -524,7 +526,7 @@ class Network(util.DaemonThread):
self.blockchain.queue.put((i,result)) self.blockchain.queue.put((i,result))
if i == self.interface: if i == self.interface:
if self.server_is_lagging() and self.config.get('auto_cycle'): if self.server_is_lagging() and self.auto_connect():
self.print_error("Server lagging, stopping interface") self.print_error("Server lagging, stopping interface")
self.stop_interface() self.stop_interface()
self.notify('updated') self.notify('updated')

Loading…
Cancel
Save