feat(builtin): add worker builtin definition [NET-397] (#42)

This commit is contained in:
Aleksey Proshutisnkiy 2023-03-22 17:21:44 +04:00 committed by GitHub
parent d7bc270d36
commit f575e71e05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 6 deletions

View File

@ -20,7 +20,6 @@ data Service:
blueprint_id: string
owner_id: string
aliases: []string
worker_aliases: []string
worker_id: string
data FunctionSignature:
@ -349,8 +348,6 @@ data SignResult:
-- Signature as byte array. Will be null if the call is not successful
signature: ?[]u8
-- Available only on FluenceJS peers
-- The service can also be resolved by it's host peer id
service Sig("sig"):
-- Signs data with the service's private key.
-- Depending on implementation the service might check call params to restrict usage for security reasons.
@ -358,9 +355,9 @@ service Sig("sig"):
-- and accepts data only from the following sources:
-- trust-graph.get_trust_bytes
-- trust-graph.get_revocation_bytes
-- registry.get_route_bytes
-- registry.get_key_bytes (for FluenceJS only)
-- registry.get_record_bytes
-- registry.get_host_record_bytes
-- registry.get_record_metadata_bytes
-- Argument: data - byte array to sign
-- Returns: signature as SignResult structure
sign(data: []u8) -> SignResult

32
workers.aqua Normal file
View File

@ -0,0 +1,32 @@
import PeerId from "./builtin.aqua"
-- Available only on rust peers
service DealWorker("worker"):
-- Creates new worker associated with `deal_id`.
-- Throws an error if worker exists.
create(deal_id: ?string) -> PeerId
-- Returns worker peer id associated with `deal_id`.
-- Throws an error if worker doesn't exist.
get_peer_id(deal_id: ?string) -> PeerId
-- Removes worker with all deployed spells and services.
-- Throws an error if worker doesn't exist.
-- Worker can be removed only by worker creator or worker itself.
remove(worker_id: PeerId)
-- Available only on rust peers
-- Suitable for direct hosting
service Worker("worker"):
-- Creates new worker associated with `init_peer_id`.
-- Throws an error if worker exists.
create() -> PeerId
-- Returns worker peer id associated with `init_peer_id`.
-- Throws an error if worker doesn't exist.
get_peer_id() -> PeerId
-- Removes worker with all deployed spells and services.
-- Throws an error if worker doesn't exist.
-- Worker can be removed only by worker creator or worker itself.
remove(worker_id: PeerId)