fix: rename variable

This commit is contained in:
callebtc 2022-12-16 17:34:05 +01:00
parent ac87c49603
commit 5d4e1dd9bb

View file

@ -153,20 +153,20 @@ class LNbitsWallet(Wallet):
async with client.stream( async with client.stream(
"GET", url, content="text/event-stream" "GET", url, content="text/event-stream"
) as r: ) as r:
sse_event = False sse_trigger = False
async for line in r.aiter_lines(): async for line in r.aiter_lines():
# The data we want to listen to is of this shape: # The data we want to listen to is of this shape:
# event: payment-received # event: payment-received
# data: {.., "payment_hash" : "asd"} # data: {.., "payment_hash" : "asd"}
if line.startswith("event: payment-received"): if line.startswith("event: payment-received"):
sse_event = True sse_trigger = True
continue continue
elif sse_event and line.startswith("data:"): elif sse_trigger and line.startswith("data:"):
data = json.loads(line[len("data:") :]) data = json.loads(line[len("data:") :])
sse_event = False sse_trigger = False
yield data["payment_hash"] yield data["payment_hash"]
else: else:
sse_event = False sse_trigger = False
except (OSError, httpx.ReadError, httpx.ConnectError, httpx.ReadTimeout): except (OSError, httpx.ReadError, httpx.ConnectError, httpx.ReadTimeout):
pass pass