Update smart contract

add-txt2txt-models
Guillermo Rodriguez 2023-06-04 14:06:41 -03:00
parent 0cb2565d65
commit d5b04a673c
No known key found for this signature in database
GPG Key ID: EC3AB66D5D83B392
5 changed files with 98 additions and 25 deletions

View File

@ -174,7 +174,10 @@ async def open_dgpu_node(
lower_bound=int(time.time()) - 3600
)
except asks.errors.RequestTimeout:
except (
asks.errors.RequestTimeout,
json.JSONDecodeError
):
return []
async def get_status_by_request_id(request_id: int):
@ -201,16 +204,6 @@ async def open_dgpu_node(
else:
return None
async def get_user_nonce(user: str):
logging.info('get_user_nonce')
return (await cleos.aget_table(
'telos.gpu', 'telos.gpu', 'users',
index_position=1,
key_type='name',
lower_bound=user,
upper_bound=user
))[0]['nonce']
async def begin_work(request_id: int):
logging.info('begin_work')
return await cleos.a_push_action(
@ -218,7 +211,8 @@ async def open_dgpu_node(
'workbegin',
{
'worker': Name(account),
'request_id': request_id
'request_id': request_id,
'max_workers': 2
},
account, key,
permission=permission
@ -328,7 +322,7 @@ async def open_dgpu_node(
if rid not in my_results:
statuses = await get_status_by_request_id(rid)
if len(statuses) < config['verification_amount']:
if len(statuses) < req['min_verification']:
# parse request
body = json.loads(req['body'])

View File

@ -148,7 +148,8 @@ class SkynetTelegramFrontend:
'user': Name(self.account),
'request_body': body,
'binary_data': binary_data,
'reward': asset_from_str(reward)
'reward': asset_from_str(reward),
'min_verification': 1
},
self.account, self.key, permission=self.permission
)

View File

@ -145,7 +145,7 @@ def open_nodeos(cleanup: bool = True):
ec, out = cleos.push_action(
'telos.gpu',
'config',
[1, 'eosio.token', '4,GPU'],
['eosio.token', '4,GPU'],
f'telos.gpu@active'
)
assert ec == 0

View File

@ -21,6 +21,40 @@
}
]
},
{
"name": "card",
"base": "",
"fields": [
{
"name": "id",
"type": "uint64"
},
{
"name": "owner",
"type": "name"
},
{
"name": "card_name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "total_memory",
"type": "uint64"
},
{
"name": "mp_count",
"type": "uint32"
},
{
"name": "extra",
"type": "string"
}
]
},
{
"name": "clean",
"base": "",
@ -30,10 +64,6 @@
"name": "config",
"base": "",
"fields": [
{
"name": "verification_amount",
"type": "uint8"
},
{
"name": "token_contract",
"type": "name"
@ -72,11 +102,15 @@
},
{
"name": "binary_data",
"type": "bytes"
"type": "string"
},
{
"name": "reward",
"type": "asset"
},
{
"name": "min_verification",
"type": "uint32"
}
]
},
@ -84,10 +118,6 @@
"name": "global_configuration_struct",
"base": "",
"fields": [
{
"name": "verification_amount",
"type": "uint8"
},
{
"name": "token_contract",
"type": "name"
@ -154,13 +184,21 @@
"name": "reward",
"type": "asset"
},
{
"name": "min_verification",
"type": "uint32"
},
{
"name": "nonce",
"type": "uint64"
},
{
"name": "body",
"type": "string"
},
{
"name": "binary_data",
"type": "bytes"
"type": "string"
},
{
"name": "timestamp",
@ -213,6 +251,10 @@
{
"name": "request_id",
"type": "uint64"
},
{
"name": "max_workers",
"type": "uint32"
}
]
},
@ -234,6 +276,28 @@
}
]
},
{
"name": "worker",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "joined",
"type": "time_point_sec"
},
{
"name": "left",
"type": "time_point_sec"
},
{
"name": "url",
"type": "string"
}
]
},
{
"name": "worker_status_struct",
"base": "",
@ -296,6 +360,13 @@
}
],
"tables": [
{
"name": "cards",
"type": "card",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "config",
"type": "global_configuration_struct",
@ -330,6 +401,13 @@
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "workers",
"type": "worker",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],