commit 2c7b10a776ecdc8ded11a5a168e30e7a4087b6fb
parent 58d5215e2e244066cfc76bf65d61c6da329a3016
Author: ThomasV <thomasv@electrum.org>
Date: Fri, 29 Jan 2016 17:35:19 +0100
Revert "Daemon network cleanup"
This reverts commit 0a1b3eac9cd297141f137075cc3de6abefab54a1.
Diffstat:
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/electrum b/electrum
@@ -328,7 +328,13 @@ if __name__ == '__main__':
if server is not None:
result = server.gui(config_options)
else:
- daemon = Daemon(config)
+ if not config.get('offline'):
+ network = Network(config)
+ network.start()
+ else:
+ network = None
+ daemon = Daemon(config, network)
+ daemon.start()
gui = init_gui(config, daemon, plugins)
daemon.gui = gui
gui.main()
@@ -345,12 +351,15 @@ if __name__ == '__main__':
elif subcommand == 'start':
p = os.fork()
if p == 0:
- daemon = Daemon(config)
+ network = Network(config)
+ network.start()
+ daemon = Daemon(config, network)
if config.get('websocket_server'):
from electrum import websockets
- websockets.WebSocketServer(config, daemon.network).start()
+ websockets.WebSocketServer(config, network).start()
if config.get('requests_dir'):
util.check_www_dir(config.get('requests_dir'))
+ daemon.start()
daemon.join()
sys.exit(0)
else:
diff --git a/lib/daemon.py b/lib/daemon.py
@@ -26,7 +26,7 @@ from wallet import WalletStorage, Wallet
from wizard import WizardBase
from commands import known_commands, Commands
from simple_config import SimpleConfig
-from network import Network
+
def lockfile(config):
return os.path.join(config.path, 'daemon')
@@ -62,16 +62,10 @@ class RequestHandler(SimpleJSONRPCRequestHandler):
class Daemon(DaemonThread):
- def __init__(self, config):
+ def __init__(self, config, network):
DaemonThread.__init__(self)
self.config = config
- if not config.get('offline'):
- self.network = Network(config)
- self.network.start()
- else:
- # FIXME: some of the daemon code assumes self.network is not None
- # This is not something this change has introduced
- self.network = None
+ self.network = network
self.gui = None
self.wallets = {}
self.wallet = None
@@ -88,7 +82,6 @@ class Daemon(DaemonThread):
self.server.register_function(self.ping, 'ping')
self.server.register_function(self.run_daemon, 'daemon')
self.server.register_function(self.run_gui, 'gui')
- self.start()
def ping(self):
return True