Replies: 3 comments
-
This isn't really something possibly in general with event emitters, as they do not coordinate with each other. You could build some simple synchronization object to manage this, but nothing built-in will help you. If the order matters a lot, I think your best bet is the Sorry I can't be of more help, but async makes a lot of things that need synchronizing difficult and more of an application-level problem... :s |
Beta Was this translation helpful? Give feedback.
-
(moving to discussions) |
Beta Was this translation helpful? Give feedback.
-
Thanks, I just wanted to know if it's possible using events. PS. I'm 100% sure that some contract level events fire twice in some circumstances. It's not reorg, those events come from the same block, with the same transaction id, and at the same position within block. Perhaps this is limited to Alchemy and its WebSocket API. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Can anyone elaborate a bit how this loop in which ethers listens to events on provider / contract works? And how I can control it?
What I have right now is:
Due to asychronous nature of it, sometimes contract.on() is fired faster than provider.on(), sometimes event from two blocks are mixed and so on.
What I would like to achieve is:
Ideally, even if some new block arrives in the middle of processing previous block, it's processed only after previous block is handled.
I know it can be done by using getLogs() but I don't think it would be a great idea since I'm listening to events on 15 or so contracts, not just one.
Is it possible using events?
Beta Was this translation helpful? Give feedback.
All reactions