Skip to content
Snippets Groups Projects
Commit 6b08836e authored by pavel.sidorenko's avatar pavel.sidorenko
Browse files

Feature: The try except block has been added to allow you to switch to the next connection option

parent c999fd6b
No related branches found
No related tags found
No related merge requests found
...@@ -45,13 +45,17 @@ class ContractProvider: ...@@ -45,13 +45,17 @@ class ContractProvider:
self.nft_token = nft_token self.nft_token = nft_token
self.network_id = network_id self.network_id = network_id
@property @property
def w3(self): def w3(self):
for url in self.urls: for url in self.urls:
web3 = Web3(HTTPProvider(url)) try:
if web3.isConnected(): web3 = Web3(HTTPProvider(url))
web3.middleware_onion.inject(geth_poa_middleware, layer=0) if web3.isConnected():
return web3 web3.middleware_onion.inject(geth_poa_middleware, layer=0)
return web3
except Exception as e:
#logIt.notice(f"Connection failed for URL {url}: {e}")
continue
raise ConnectionError("No valid links provided - failed to connect") raise ConnectionError("No valid links provided - failed to connect")
@property @property
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment