trust-graph/example/aqua/computation.aqua
InversionSpaces 175e51d5db
feat(trust-graph): Update aqua code (#141)
* Update aqua

* Update aqua-lib

* Update admin aqua

* Remove aqua dep

* Update example aqua

* Fix package.json

* Update admin/package.json

Co-authored-by: Aleksey Proshutinskiy <justprosh@users.noreply.github.com>

* Update aqua/package.json

Co-authored-by: Aleksey Proshutinskiy <justprosh@users.noreply.github.com>

* Update example/package.json

Co-authored-by: Aleksey Proshutinskiy <justprosh@users.noreply.github.com>

* Setup fluence in CI

---------

Co-authored-by: Aleksey Proshutinskiy <justprosh@users.noreply.github.com>
2023-12-29 13:46:10 +01:00

34 lines
1.0 KiB
Plaintext

aqua Computation
import "@fluencelabs/trust-graph/trust-graph-api.aqua"
import "@fluencelabs/trust-graph/trust-graph.aqua"
import "@fluencelabs/aqua-lib/builtin.aqua"
export trusted_computation
service CertOp("op"):
array_length(a: []Certificate) -> u32
service TrustedComputation("op"):
identity(s: u64) -> u64
func trusted_computation(node: string) -> ?u64, ?string:
result: *u64
error: *string
-- on our trusted relay
on HOST_PEER_ID:
-- get all certificates issued for given node by our client's peer id
certs_result <- get_all_certs_from(node, INIT_PEER_ID)
if certs_result.success:
len <- CertOp.array_length(certs_result.certificates)
-- if there is any certificate node is trusted and computation is possible
if len != 0:
on node:
result <- TrustedComputation.identity(5)
else:
error <<- "there is no certs for this peer"
else:
error <<- certs_result.error
<- result, error