electrum

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

commit 3b00f62d4681c43fafa6f1903bb6d5cce6f8efa8
parent 1c83c3e06035cd2fb968367bdffda77e714fb827
Author: ThomasV <thomasv@electrum.org>
Date:   Mon,  1 Feb 2016 09:25:57 +0100

remove another unnecessary static method

Diffstat:
Melectrum | 11+++++++----
Mlib/daemon.py | 24+++++++++---------------
2 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/electrum b/electrum @@ -316,11 +316,13 @@ if __name__ == '__main__': lockfile = Daemon.lockfile(config) fd = Daemon.get_fd_or_server(lockfile) if isinstance(fd, int): - daemon = Daemon.create_daemon(config, fd) + daemon = Daemon(config, fd) + daemon.start() daemon.init_gui(config, plugins) sys.exit(0) - server = fd - result = server.gui(config_options) + else: + server = fd + result = server.gui(config_options) elif cmdname == 'daemon': lockfile = Daemon.lockfile(config) @@ -337,7 +339,8 @@ if __name__ == '__main__': if pid: print_stderr("starting daemon (PID %d)" % pid) sys.exit(0) - daemon = Daemon.create_daemon(config, fd) + daemon = Daemon(config, fd) + daemon.start() if config.get('websocket_server'): from electrum import websockets websockets.WebSocketServer(config, daemon.network).start() diff --git a/lib/daemon.py b/lib/daemon.py @@ -48,7 +48,8 @@ class RequestHandler(SimpleJSONRPCRequestHandler): class Daemon(DaemonThread): - def __init__(self, config, server): + def __init__(self, config, fd): + DaemonThread.__init__(self) self.config = config if config.get('offline'): @@ -58,9 +59,14 @@ class Daemon(DaemonThread): self.network.start() self.gui = None self.wallets = {} - self.server = server # Setup server cmd_runner = Commands(self.config, None, self.network) + host = config.get('rpchost', 'localhost') + port = config.get('rpcport', 0) + server = SimpleJSONRPCServer((host, port), logRequests=False, + requestHandler=RequestHandler) + os.write(fd, repr((server.socket.getsockname(), time.time()))) + os.close(fd) server.timeout = 0.1 for cmdname in known_commands: server.register_function(getattr(cmd_runner, cmdname), cmdname) @@ -68,6 +74,7 @@ class Daemon(DaemonThread): server.register_function(self.ping, 'ping') server.register_function(self.run_daemon, 'daemon') server.register_function(self.run_gui, 'gui') + self.server = server def ping(self): return True @@ -221,16 +228,3 @@ class Daemon(DaemonThread): # Sleep a bit and try again; it might have just been started time.sleep(1.0) - @staticmethod - def create_daemon(config, fd): - '''Create a daemon and server when they don't exist.''' - host = config.get('rpchost', 'localhost') - port = config.get('rpcport', 0) - server = SimpleJSONRPCServer((host, port), logRequests=False, - requestHandler=RequestHandler) - os.write(fd, repr((server.socket.getsockname(), time.time()))) - os.close(fd) - - daemon = Daemon(config, server) - daemon.start() - return daemon