daemon: fix long-standing bug in status request

Gracefully handle a status request when self.network is None
This commit is contained in:
Neil Booth 2016-01-31 11:50:44 +09:00
parent ec24087b5a
commit f91f03b3d4
1 changed files with 15 additions and 11 deletions

View File

@ -100,17 +100,21 @@ class Daemon(DaemonThread):
if sub == 'start': if sub == 'start':
response = "Daemon already running" response = "Daemon already running"
elif sub == 'status': elif sub == 'status':
p = self.network.get_parameters() if self.network:
response = { p = self.network.get_parameters()
'path': self.network.config.path, response = {
'server': p[0], 'path': self.network.config.path,
'blockchain_height': self.network.get_local_height(), 'server': p[0],
'server_height': self.network.get_server_height(), 'blockchain_height': self.network.get_local_height(),
'nodes': self.network.get_interfaces(), 'server_height': self.network.get_server_height(),
'connected': self.network.is_connected(), 'nodes': self.network.get_interfaces(),
'auto_connect': p[4], 'connected': self.network.is_connected(),
'wallets': dict([ (k, w.is_up_to_date()) for k, w in self.wallets.items()]), 'auto_connect': p[4],
} 'wallets': {k: w.is_up_to_date()
for k, w in self.wallets.items()},
}
else:
response = "Daemon offline"
elif sub == 'stop': elif sub == 'stop':
self.stop() self.stop()
response = "Daemon stopped" response = "Daemon stopped"