2021-04-14 17:56:39 +03:00
|
|
|
-- set `PeerId` name to be a type alias for `string` type
|
2021-04-13 18:22:51 +03:00
|
|
|
alias PeerId : string
|
|
|
|
|
2021-04-14 17:56:39 +03:00
|
|
|
-- define data structure (ADT)
|
2021-04-13 18:22:51 +03:00
|
|
|
data NodeId:
|
|
|
|
peerId: PeerId
|
|
|
|
name: string
|
|
|
|
|
2021-04-15 12:45:18 +03:00
|
|
|
-- define service `NodeIdGetter` that will be callable on local client via `somesrv` service id
|
|
|
|
service NodeIdGetter("somesrv"):
|
2021-04-13 18:22:51 +03:00
|
|
|
get: -> NodeId
|
|
|
|
|
2021-04-15 12:45:18 +03:00
|
|
|
-- showcases a function that gets data structure from a local service,
|
|
|
|
-- and then retrieves aliased data type from that structure
|
|
|
|
func getAliasedData() -> PeerId:
|
|
|
|
res <- NodeIdGetter.get()
|
2021-04-14 17:32:01 +03:00
|
|
|
<- res.peerId
|