web3.py: Multiple Providers Call to highest block number
- Version: latest
- Python:3.5
- OS: win
What was wrong?
I think it is wrong (not 100% sure )! Right now I’m using infura as HTTP Provider and want to add a localhost provider running geth. So the natural way would be:
web3 = Web3([geth_local_host_provider, infura_provider])
Now as I understand web3 makes always the first request to geth_local_host_provider and if it fails it tries infura_provider. In my case sometimes geth get out of sync. So the actual block number is different. I think the right strategy would be to make the “request” to the HTTP Provider with the highest block.
How can it be fixed?
Check first the block’s of every provider and filter if any provider in the list has a lower block number.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (15 by maintainers)
I completely agree. If we don’t have anything using it by the time that v5.x is on the horizon we would plan to deprecate and remove it.
I don’t think your proposed solution will work for us, but I do think this is an issue that we should look into providing at minimum the tools for solving. This strikes me as something that should be solveable with our middleware layer, but I think it may be tough as things currently stand because middlewares don’t have visibility across multiple providers.
cc @carver