You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try:
self.web3.middleware_onion.inject(geth_poa_middleware, layer=0)
exceptMiddlewareAlreadyAddedError:
pass# Is ok
Note: We prefer to use issues to track our work. If you think you've encountered a bug in web3py or
have a feature request, you're in the right place. If you have implementation or usage questions,
please refer to our documentation and/or join the conversation
on discord.
The text was updated successfully, but these errors were encountered:
pip freeze
outputWhat was wrong?
OK, right now if you try to add middleware that already exists, youll hit this line: https://github.com/ethereum/web3.py/blob/main/web3/datastructures.py#L174
and one way to handle this downstream is like this:
but it doesn't seem very reliable and try/except is always a last-resort.
How can it be fixed?
Add a method, perhaps
__contains__
, that allows me to only add middleware if it is not already added.I'd like to write it like this:
Alternatively, a custom error would work:
Note: We prefer to use issues to track our work. If you think you've encountered a bug in web3py or
have a feature request, you're in the right place. If you have implementation or usage questions,
please refer to our documentation and/or join the conversation
on discord.
The text was updated successfully, but these errors were encountered: