Skip to content
Snippets Groups Projects
Commit 16d1976f authored by Dmitry Puzyrkov's avatar Dmitry Puzyrkov
Browse files

Merge branch 'Feature-10033' into 'main'

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

See merge request cellframe/pycfhelpers!8
parents c999fd6b 6b08836e
No related branches found
No related tags found
No related merge requests found
......@@ -45,13 +45,17 @@ class ContractProvider:
self.nft_token = nft_token
self.network_id = network_id
@property
def w3(self):
for url in self.urls:
web3 = Web3(HTTPProvider(url))
if web3.isConnected():
web3.middleware_onion.inject(geth_poa_middleware, layer=0)
return web3
@property
def w3(self):
for url in self.urls:
try:
web3 = Web3(HTTPProvider(url))
if web3.isConnected():
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")
@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