feat: load web3 provider in the master node

This commit is contained in:
snsd0805 2024-05-31 01:58:04 +08:00
parent 87646d9661
commit 12caa7358f
Signed by: snsd0805
GPG Key ID: 569349933C77A854

View File

@ -29,7 +29,8 @@ class NodeManager():
self.docker_client = docker.from_env()
# web3 provider
self.w3 = Web3(Web3.HTTPProvider(WEB3_PROVIDER_URL + WEB3_PROVIDER_KEY))
# if this is master, it should init a Web object.
self.w3 = None
time.sleep(2)
@ -74,9 +75,20 @@ class NodeManager():
print("No other nodes in your subnet.")
def start_listen_task(self):
self.w3 = Web3(Web3.HTTPProvider(WEB3_PROVIDER_URL + WEB3_PROVIDER_KEY))
print(f"We have use {WEB3_PROVIDER_URL+WEB3_PROVIDER_KEY} as the web3 provider.")
print(f"And we have load your wallet private key {WALLET_KEY}")
print()
if self.w3.is_connected():
print("Connected Successfully.")
print()
print("Waiting for the new task from Sepolia testnet...")
self.cluster_communication_module.start_listen_task()
else:
print("Connected Failed.")
print("Please check for your provider key & wallet key")
def cluster_info(self):
info = self.cluster_communication_module.cluster_info()