web3dart icon indicating copy to clipboard operation
web3dart copied to clipboard

Custom filter refresh interval

Open alexeyinkin opened this issue 3 years ago • 0 comments

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:

  1. Make an option to override this interval.
  2. 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:

  1. Deprecate Web3Client.pendingTransactions and add a separate method with interval argument.
  2. Breaking change: Add a required argument to Web3Client.pendingTransactions since it is a very convenient name.
  3. Breaking change: Add an optional argument to Web3Client.pendingTransactions with the default of no waiting.
  4. 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:

  1. Do the Option 1 if we do this before the next breaking release.
  2. In the next breaking release, remove pendingTransactions.
  3. In yet the next breaking release do the Option 3.

Meanwhile another solution to refresh the filter at custom interval is to do

  • #5

alexeyinkin avatar Feb 24 '22 06:02 alexeyinkin