Modify order of adding middlewares, poa first (layer 0), then retry, then simple cache.

v7.4.1-hotfix^2
derekpierre 2024-09-04 09:15:19 -04:00
parent b22fd0fcb5
commit 5892b67d23
No known key found for this signature in database
1 changed files with 9 additions and 9 deletions

View File

@ -80,6 +80,15 @@ class EthereumClient:
self._add_default_middleware()
def _add_default_middleware(self):
# add POA middleware irrespective of chain
poa_middleware_name = "poa"
self.log.info("Injecting POA middleware at layer 0")
self.inject_middleware(
geth_poa_middleware,
layer=0,
name=poa_middleware_name,
)
# retry request middleware
endpoint_uri = getattr(self.w3.provider, "endpoint_uri", "")
if "infura" in endpoint_uri:
@ -92,15 +101,6 @@ class EthereumClient:
self.log.info("Adding RPC retry middleware to client")
self.add_middleware(RetryRequestMiddleware, name="retry")
# add POA middleware irrespective of chain
poa_middleware_name = "poa"
self.log.info("Injecting POA middleware at layer 0")
self.inject_middleware(
geth_poa_middleware,
layer=0,
name=poa_middleware_name,
)
# simple cache middleware
self.log.info("Adding simple_cache_middleware")
self.add_middleware(simple_cache_middleware, name="simple_cache")