35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from web3 import Web3
|
|
from src.scheduler import Scheduler
|
|
|
|
SCHEDULER_ADDR = "0x544eAe853EA3774A8857573C6423E6Db95b79258"
|
|
SCHEDULER_ABI_FILE = "../gpu-contract/abi/Scheduler.abi"
|
|
|
|
PROVIDER1_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
|
PROVIDER2_KEY = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
|
|
PROVIDER3_KEY = "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
|
|
|
|
CLIENT_KEY = "0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6"
|
|
|
|
w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545'))
|
|
|
|
if __name__ == '__main__':
|
|
if w3.is_connected():
|
|
scheduler = Scheduler(w3, SCHEDULER_ADDR, SCHEDULER_ABI_FILE)
|
|
|
|
provider1 = w3.eth.account.from_key(PROVIDER1_KEY)
|
|
provider2 = w3.eth.account.from_key(PROVIDER2_KEY)
|
|
provider3 = w3.eth.account.from_key(PROVIDER3_KEY)
|
|
client = w3.eth.account.from_key(CLIENT_KEY)
|
|
|
|
print(scheduler.getClusters())
|
|
scheduler.registerCluster(provider1, 1, 4)
|
|
scheduler.registerCluster(provider2, 2, 2)
|
|
scheduler.registerCluster(provider3, 3, 1)
|
|
scheduler.registerTaskWithConditions(client, "https://data.com", "http://train.tw", 3, 1)
|
|
print(scheduler.getClusters())
|
|
print(scheduler.getTasks())
|
|
|
|
else:
|
|
print("cannot connected to the chain")
|
|
|