mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-01-07 16:13:06 +00:00
do not crash polling when just unsubscribed
This commit is contained in:
parent
c6a59b5187
commit
f15d55f513
@ -171,13 +171,11 @@ proc new*(_: type JsonRpcSubscriptions,
|
|||||||
discard
|
discard
|
||||||
|
|
||||||
proc getChanges(id: JsonNode): Future[JsonNode] {.async: (raises: [CancelledError]).} =
|
proc getChanges(id: JsonNode): Future[JsonNode] {.async: (raises: [CancelledError]).} =
|
||||||
|
if mappedId =? subscriptions.subscriptionMapping.?[id]:
|
||||||
try:
|
try:
|
||||||
let mappedId = subscriptions.subscriptionMapping[id]
|
|
||||||
let changes = await subscriptions.client.eth_getFilterChanges(mappedId)
|
let changes = await subscriptions.client.eth_getFilterChanges(mappedId)
|
||||||
if changes.kind == JArray:
|
if changes.kind == JArray:
|
||||||
return changes
|
return changes
|
||||||
except KeyError as error:
|
|
||||||
raiseAssert "subscription mapping invalid: " & error.msg
|
|
||||||
except JsonRpcError:
|
except JsonRpcError:
|
||||||
await resubscribe(id)
|
await resubscribe(id)
|
||||||
# TODO: we could still miss some events between losing the subscription
|
# TODO: we could still miss some events between losing the subscription
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user