electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 5e6a55edd58940bd1d377a9bb26d42df48c60446
parent 012f500976d326a27d523de6dc5ecd123fef4125
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 30 Jan 2016 11:13:11 +0100

Revert "Revert "Daemon network cleanup""

This reverts commit 2c7b10a776ecdc8ded11a5a168e30e7a4087b6fb.

Diffstat:
Melectrum | 15+++------------
Mlib/daemon.py | 13++++++++++---
2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/electrum b/electrum @@ -328,13 +328,7 @@ if __name__ == '__main__': if server is not None: result = server.gui(config_options) else: - if not config.get('offline'): - network = Network(config) - network.start() - else: - network = None - daemon = Daemon(config, network) - daemon.start() + daemon = Daemon(config) gui = init_gui(config, daemon, plugins) daemon.gui = gui gui.main() @@ -351,15 +345,12 @@ if __name__ == '__main__': elif subcommand == 'start': p = os.fork() if p == 0: - network = Network(config) - network.start() - daemon = Daemon(config, network) + daemon = Daemon(config) if config.get('websocket_server'): from electrum import websockets - websockets.WebSocketServer(config, network).start() + websockets.WebSocketServer(config, daemon.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,10 +62,16 @@ class RequestHandler(SimpleJSONRPCRequestHandler): class Daemon(DaemonThread): - def __init__(self, config, network): + def __init__(self, config): DaemonThread.__init__(self) self.config = config - self.network = network + 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.gui = None self.wallets = {} self.wallet = None @@ -82,6 +88,7 @@ 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