-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Filters that don't rely on server state #551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I just realized this fits perfectly into the middleware framework. No need for a new API, just a new middleware. |
It's worth taking a look at the issues that the following project has with filters in v3: https://github.com/makerdao/pymaker/blob/7f2047b87d6982ce3cfadae07b8fad0026896202/pymaker/lifecycle.py I think this proposal does a great job of addressing them all, but a thorough look before implementing this approach would be wise. |
Any idea when this could get in? |
I suspect it will be part of the next major release cycle but there's no firm timeline for when that will be. |
Im starting on this. |
Looks like the pull request is about to be merged in. Excited to try this out in the next release! I implemented something using filters only to find out that Infura doesn't support them :( |
#732 Was merged. @jasonrhaas Give it a try, and let me know what you think! |
@dylanjw @carver @pipermerriam Any chance of getting this feature into the new web3py release? I am trying to use filters and have found them horribly unreliable and inconsistent. Hoping that this middleware is a good alternative. |
Sure, I should be able to get it out tomorrow morning. Note that it would be a v5 alpha release, so no guarantees about a stable API for a little while. |
What was wrong?
Filters suck.
filter_id
How can it be fixed?
I propose we implement a new opt-in middleware to handle log filters locally.
Consider the following generator.
This
log_filter
generator can be used under the hood in place of using the node based filters to handle all filter logic locally, only relying on the node foreth_getLogs
which is stateless.The middleware would then resemble the following.
The middleware creates and tracks these generator functions locally, retrieving them when requests are made to retrieve the logs for a given filter and using them to return the appropriate log entries.
Each time a new filter is created, the filter backend will create one of these generators for it and keep track of it internally. Then, any calls to
eth_getFilterChanges
can just return thenext(...)
for the appropriate filter generator. We should be able to do something similar witheth_getFilterLogs
by re-generating the original filter generator and then returning all of the values up-to-the-current state of the generator.The text was updated successfully, but these errors were encountered: