1
0
mirror of https://github.com/fluencelabs/aqua-playground synced 2025-03-17 00:30:56 +00:00
2021-11-04 14:26:50 +03:00

51 lines
1.1 KiB
Plaintext

module Closure declares *
import "@fluencelabs/aqua-lib/builtin.aqua"
export LocalSrv, closureIn, closureOut, closureBig
service MyOp("op"):
identity(s: string) -> string
service LocalSrv("local_srv"):
inside: -> ()
func closureIn(peer1: string) -> string:
variable = "const"
co on peer1:
p1Id <- MyOp.identity("co on")
closure = (s: string) -> string:
if s == "in":
LocalSrv.inside()
p2Id <- MyOp.identity(s)
<- p2Id
p <- closure("in")
<- p
func closureOut(peer2: string) -> Info:
closure = (s: string) -> Info:
if s == "in":
LocalSrv.inside()
p2Id <- Peer.identify()
<- p2Id
on peer2:
p2Id <- closure("on")
<- p2Id
func closureBig(peer1: string, peer2: string) -> string, string:
variable = "const"
co on peer1:
p1Id <- MyOp.identity("co on")
closure = (s: string) -> string:
p2Id: *string
if s == "in":
p2 <- MyOp.identity(s)
p2Id <<- p2
else:
p2Info <- Peer.identify()
p2Id <<- p2Info.external_addresses!0
<- p2Id!
p <- closure("in")
on peer2:
p2Id <- closure("on")
<- p, p2Id