From 7314c71695ccfb0a1a9ac274620921204785e15a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 17 Dec 2018 23:35:26 +0100 Subject: [PATCH] pylightning: Increase buffer size for big JSON-RPC responses This was causing `listchannels` to be incredibly slow. The response is several megabyte in size, and we were only buffering 1Kb on each iteration. Signed-off-by: Christian Decker --- contrib/pylightning/lightning/lightning.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/pylightning/lightning/lightning.py b/contrib/pylightning/lightning/lightning.py index 9ffcc10f4..18466ee77 100644 --- a/contrib/pylightning/lightning/lightning.py +++ b/contrib/pylightning/lightning/lightning.py @@ -33,7 +33,7 @@ class UnixDomainSocketRpc(object): return self._readobj(sock, buff) while True: try: - b = sock.recv(1024) + b = sock.recv(max(1024, len(buff))) buff += b if b'\n\n' in buff: @@ -58,7 +58,7 @@ class UnixDomainSocketRpc(object): parts = buff.split(b'\n\n', 1) if len(parts) == 1: # Didn't read enough. - b = sock.recv(1024) + b = sock.recv(max(1024, len(buff))) buff += b if len(b) == 0: return {'error': 'Connection to RPC server lost.'}, buff