fix: rename variable
This commit is contained in:
parent
ac87c49603
commit
5d4e1dd9bb
1 changed files with 5 additions and 5 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue