Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)