Skip to content

Commit

Permalink
feat(builtin): add worker builtin definition [NET-397] (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
justprosh authored Mar 22, 2023
1 parent d7bc270 commit f575e71
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
9 changes: 3 additions & 6 deletions builtin.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ data Service:
blueprint_id: string
owner_id: string
aliases: []string
worker_aliases: []string
worker_id: string

data FunctionSignature:
Expand Down Expand Up @@ -349,18 +348,16 @@ 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.
-- By default it is only allowed to be used on the same peer the particle was initiated
-- 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
Expand All @@ -371,7 +368,7 @@ service Sig("sig"):
-- Gets the peer id of the service's key pair.
get_peer_id() -> string

-- Available only on rust peers
-- Available only on rust peers
-- Aquire service statistic
service Stat("stat"):
-- Detailed stats for the service and its interface functions
Expand Down
32 changes: 32 additions & 0 deletions workers.aqua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit f575e71

Please sign in to comment.