web3dart
web3dart copied to clipboard
Custom filter refresh interval
Currently filters like eth_newPendingTransactionFilter
refresh interval is hardcoded to be 2 seconds with _pingDuration
constant in filters.dart
. Then a timer is used with this interval. While 2 seconds may be enough for frontrunners on Ethereum with their long block, it is not enough for blockchains with shorter blocks and for backrunning on any blockchains.
I suggest to:
- Make an option to override this interval.
- Instead of a timer, use a loop with await Future.delayed().
Particularly, a loop solution would allow to not wait between calls for extreme extreme solutions.
For the interface we have the following options:
- Deprecate
Web3Client.pendingTransactions
and add a separate method with interval argument. - Breaking change: Add a required argument to
Web3Client.pendingTransactions
since it is a very convenient name. - Breaking change: Add an optional argument to
Web3Client.pendingTransactions
with the default of no waiting. - Add an option to
Web3Client
to set all filters' intervals.
From the interface design point of view, (3) is the best, but it would change the behavior without breaking builds. So I suggest the roadmap:
- Do the Option 1 if we do this before the next breaking release.
- In the next breaking release, remove
pendingTransactions
. - In yet the next breaking release do the Option 3.
Meanwhile another solution to refresh the filter at custom interval is to do
- #5