pylightning: Don't attempt to deserialize after every read

We make use of the structure of the final read to decide when to deserialize.
This commit is contained in:
Christian Decker 2018-07-13 14:15:37 +02:00 committed by Rusty Russell
parent 760b053d7b
commit 356dcbba97

View file

@ -29,6 +29,10 @@ class UnixDomainSocketRpc(object):
buff += b
if len(b) == 0:
return {'error': 'Connection to RPC server lost.'}
if buff[-3:] != b' }\n':
continue
# Convert late to UTF-8 so glyphs split across recvs do not
# impact us
objs, _ = self.decoder.raw_decode(buff.decode("UTF-8"))