tdaemon: create network inside constructor - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit f6f7113978f2e21c44b1678e4b4f45ab2e0c392c DIR parent 7c7722439bfe29a9efeb74c6c57474d7e6cdfc1a HTML Author: Neil Booth <kyuupichan@gmail.com> Date: Sun, 31 Jan 2016 10:58:27 +0900 daemon: create network inside constructor Diffstat: M electrum | 13 +++---------- M lib/daemon.py | 9 +++++++-- 2 files changed, 10 insertions(+), 12 deletions(-) --- DIR diff --git a/electrum b/electrum t@@ -328,12 +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 = Daemon(config) daemon.start() gui = init_gui(config, daemon, plugins) daemon.gui = gui t@@ -351,12 +346,10 @@ 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() DIR diff --git a/lib/daemon.py b/lib/daemon.py t@@ -21,6 +21,7 @@ import ast, os import jsonrpclib from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer, SimpleJSONRPCRequestHandler +from network import Network from util import json_decode, DaemonThread from wallet import WalletStorage, Wallet from wizard import WizardBase t@@ -62,10 +63,14 @@ 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 config.get('offline'): + self.network = None + else: + self.network = Network(config) + self.network.start() self.gui = None self.wallets = {} self.wallet = None