tdaemon: filter notificaions sent to client - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 50bc50d78dda7b70d8f4c7f888934c180f36c5a2 DIR parent 8fb14bb5feef01fdd8da973acb17d228ad00a169 HTML Author: ThomasV <thomasv@gitorious> Date: Mon, 20 Apr 2015 09:16:43 +0200 daemon: filter notificaions sent to client Diffstat: M lib/daemon.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- DIR diff --git a/lib/daemon.py b/lib/daemon.py t@@ -73,6 +73,7 @@ class ClientThread(util.DaemonThread): self.client_pipe = util.SocketPipe(s) self.response_queue = Queue.Queue() self.server.add_client(self) + self.subscriptions = set() def reading_thread(self): while self.is_running(): t@@ -83,9 +84,13 @@ class ClientThread(util.DaemonThread): if request is None: self.running = False break - if request.get('method') == 'daemon.stop': + method = request.get('method') + params = request.get('params') + if method == 'daemon.stop': self.server.stop() continue + if method[-10:] == '.subscribe': + self.subscriptions.add(repr((method, params))) self.server.send_request(self, request) def run(self): t@@ -165,8 +170,11 @@ class NetworkServer(util.DaemonThread): client.response_queue.put(response) else: # notification + m = response.get('method') + v = response.get('params') for client in self.clients: - client.response_queue.put(response) + if repr((m, v)) in client.subscriptions: + client.response_queue.put(response) self.network.stop() print_error("server exiting")