mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-01-04 06:33:07 +00:00
Rename the symbol for better clarity
This commit is contained in:
parent
d1b54beec5
commit
359f04e7ec
@ -209,7 +209,7 @@ Workaround
|
|||||||
|
|
||||||
If you're working with Hardhat, you might encounter an issue where [subscriptions stop working after 5 minutes](https://github.com/NomicFoundation/hardhat/issues/2053).
|
If you're working with Hardhat, you might encounter an issue where [subscriptions stop working after 5 minutes](https://github.com/NomicFoundation/hardhat/issues/2053).
|
||||||
|
|
||||||
This library provides a workaround using the `--define:resubscribe` option. When this symbol is defined, the subscriptions will automatically resubscribe after 4 minutes.
|
This library provides a workaround using the `--define:ws_resubscribe` option. When this symbol is defined, the subscriptions will automatically resubscribe after 4 minutes.
|
||||||
|
|
||||||
Contribution
|
Contribution
|
||||||
------------
|
------------
|
||||||
|
|||||||
@ -8,3 +8,4 @@ when fileExists("nimble.paths"):
|
|||||||
|
|
||||||
when (NimMajor, NimMinor) >= (2, 0):
|
when (NimMajor, NimMinor) >= (2, 0):
|
||||||
--mm:refc
|
--mm:refc
|
||||||
|
--define:ws_resubscribe
|
||||||
|
|||||||
@ -24,14 +24,14 @@ type
|
|||||||
# about them
|
# about them
|
||||||
# This is used of resubscribe all the subscriptions when using websocket with hardhat
|
# This is used of resubscribe all the subscriptions when using websocket with hardhat
|
||||||
logFilters: Table[JsonNode, EventFilter]
|
logFilters: Table[JsonNode, EventFilter]
|
||||||
when defined(resubscribe):
|
when defined(ws_resubscribe):
|
||||||
resubscribeFut: Future[void]
|
resubscribeFut: Future[void]
|
||||||
MethodHandler* = proc (j: JsonNode) {.gcsafe, raises: [].}
|
MethodHandler* = proc (j: JsonNode) {.gcsafe, raises: [].}
|
||||||
SubscriptionCallback = proc(id: JsonNode, arguments: ?!JsonNode) {.gcsafe, raises:[].}
|
SubscriptionCallback = proc(id: JsonNode, arguments: ?!JsonNode) {.gcsafe, raises:[].}
|
||||||
|
|
||||||
{.push raises:[].}
|
{.push raises:[].}
|
||||||
|
|
||||||
when defined(resubscribe):
|
when defined(ws_resubscribe):
|
||||||
# This is a workaround to manage the 5 minutes limit due to hardhat.
|
# This is a workaround to manage the 5 minutes limit due to hardhat.
|
||||||
# See https://github.com/NomicFoundation/hardhat/issues/2053#issuecomment-1061374064
|
# See https://github.com/NomicFoundation/hardhat/issues/2053#issuecomment-1061374064
|
||||||
proc resubscribeWebsocketEventsOnTimeout*(subscriptions: JsonRpcSubscriptions) {.async.} =
|
proc resubscribeWebsocketEventsOnTimeout*(subscriptions: JsonRpcSubscriptions) {.async.} =
|
||||||
@ -110,7 +110,7 @@ method close*(subscriptions: JsonRpcSubscriptions) {.async: (raises: [Subscripti
|
|||||||
for id in ids:
|
for id in ids:
|
||||||
await subscriptions.unsubscribe(id)
|
await subscriptions.unsubscribe(id)
|
||||||
|
|
||||||
when defined(resubscribe):
|
when defined(ws_resubscribe):
|
||||||
if not subscriptions.resubscribeFut.isNil:
|
if not subscriptions.resubscribeFut.isNil:
|
||||||
await subscriptions.resubscribeFut.cancelAndWait()
|
await subscriptions.resubscribeFut.cancelAndWait()
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ proc new*(_: type JsonRpcSubscriptions,
|
|||||||
callback(id, success(arguments))
|
callback(id, success(arguments))
|
||||||
subscriptions.setMethodHandler("eth_subscription", subscriptionHandler)
|
subscriptions.setMethodHandler("eth_subscription", subscriptionHandler)
|
||||||
|
|
||||||
when defined(resubscribe):
|
when defined(ws_resubscribe):
|
||||||
subscriptions.resubscribeFut = resubscribeWebsocketEventsOnTimeout(subscriptions)
|
subscriptions.resubscribeFut = resubscribeWebsocketEventsOnTimeout(subscriptions)
|
||||||
|
|
||||||
subscriptions
|
subscriptions
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user