Ignore errors while polling

This commit is contained in:
Mark Spanbroek 2023-06-27 14:56:45 +02:00 committed by markspanbroek
parent 50cfd9d9dd
commit 0322ae1451
1 changed files with 7 additions and 1 deletions

View File

@ -105,8 +105,14 @@ proc new*(_: type JsonRpcSubscriptions,
let subscriptions = PollingSubscriptions(client: client)
proc getChanges(id: JsonNode): Future[JsonNode] {.async.} =
try:
return await subscriptions.client.eth_getFilterChanges(id)
except CatchableError:
return newJArray()
proc poll(id: JsonNode) {.async.} =
for change in await subscriptions.client.eth_getFilterChanges(id):
for change in await getChanges(id):
if callback =? subscriptions.getCallback(id):
callback(id, change)