This commit is contained in:
Pavel Murygin 2021-10-29 12:23:13 +03:00
parent b5dfe4365f
commit 5a2dbc0bc9
6 changed files with 297 additions and 167 deletions

View File

@ -1,34 +1,44 @@
import "@fluencelabs/aqua-lib/builtin.aqua"
alias FakeTuple: u64
alias PeerInfoCb: PeerId, Info, []Service, []Blueprint, []Module -> ()
alias ServiceInterfaceCb: PeerId, string, Interface -> ()
alias ServiceInterfaceCb: PeerId, []FakeTuple -> ()
alias Log: string -> ()
func collectServiceInterfaces(peer: PeerId, services: []Service, collectServiceInterface: ServiceInterfaceCb):
for srv <- services par:
on peer:
service MyOp("op"):
array(i: Interface, s: string) -> FakeTuple
func collectServiceInterfaces(peer: PeerId, services: []Service, collectServiceInterface: ServiceInterfaceCb, log: Log):
ifaces: *FakeTuple
on peer:
for srv <- services:
iface <- Srv.get_interface(srv.id)
collectServiceInterface(peer, srv.id, iface)
ifaces <- MyOp.array(iface, srv.id)
collectServiceInterface(peer, ifaces)
func askAllAndSend(peer: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
func askAllAndSend(peer: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb, log: Log):
on peer via HOST_PEER_ID:
ident <- Peer.identify()
blueprints <- Dist.list_blueprints()
modules <- Dist.list_modules()
services <- Srv.list()
collectPeerInfo(peer, ident, services, blueprints, modules)
collectServiceInterfaces(peer, services, collectServiceInterface)
co log("b4 collectPeerInfo")
co collectPeerInfo(peer, ident, services, blueprints, modules)
co log("b4 collectServiceInterfaces")
-- collectServiceInterfaces(peer, services, collectServiceInterface, log)
-- co log("after collectServiceInterfaces")
func findAndAskNeighboursSchema(relayPeerId: PeerId, clientId: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
func findAndAskNeighboursSchema(relayPeerId: PeerId, clientId: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb, log: Log):
on relayPeerId:
neighbors <- Kademlia.neighborhood(clientId, nil, nil)
for n <- neighbors par:
on n:
neighbors2 <- Kademlia.neighborhood(clientId, nil, nil)
for n2 <- neighbors2 par:
askAllAndSend(n2, collectPeerInfo, collectServiceInterface)
askAllAndSend(n2, collectPeerInfo, collectServiceInterface, log)
func getAll(knownPeers: []PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
func getAll(knownPeers: []PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb, log: Log):
on HOST_PEER_ID:
-- co askAllAndSend(relayPeerId, collectPeerInfo, collectServiceInterface)
@ -36,6 +46,6 @@ func getAll(knownPeers: []PeerId, collectPeerInfo: PeerInfoCb, collectServiceInt
-- we gather data from the known peers only.
-- Known peers are explicitly represent the whole network atm
for peer <- knownPeers par:
askAllAndSend(peer, collectPeerInfo, collectServiceInterface)
askAllAndSend(peer, collectPeerInfo, collectServiceInterface, log)
-- co findAndAskNeighboursSchema(relayPeerId, %init_peer_id%, collectPeerInfo, collectServiceInterface)

14
package-lock.json generated
View File

@ -18,7 +18,7 @@
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@fluencelabs/aqua": "^0.4.0-235",
"@fluencelabs/aqua": "^0.4.0-238",
"@fluencelabs/aqua-lib": "0.1.14",
"@types/yup": "^0.29.11",
"babel-loader": "^8.1.0",
@ -1278,9 +1278,9 @@
}
},
"node_modules/@fluencelabs/aqua": {
"version": "0.4.0-235",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.4.0-235.tgz",
"integrity": "sha512-tbbHG3dhlwcSzlHMPoV4/MLW6JE00q3hiyznjLh+aW91ovBAXuWe5C1n9CKeRiJtYz3yIQCn2l3arI/PvzLx9Q==",
"version": "0.4.0-238",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.4.0-238.tgz",
"integrity": "sha512-vSie7LinYIF+WoCz16yVduGsjLL0JO6gNBi1q0WtHHXCZiLn7d7m+gNacVrIbPrI9bwUht0U6kJd6xFKqXBUhw==",
"dev": true,
"dependencies": {
"@fluencelabs/fluence": "0.12.1"
@ -19450,9 +19450,9 @@
}
},
"@fluencelabs/aqua": {
"version": "0.4.0-235",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.4.0-235.tgz",
"integrity": "sha512-tbbHG3dhlwcSzlHMPoV4/MLW6JE00q3hiyznjLh+aW91ovBAXuWe5C1n9CKeRiJtYz3yIQCn2l3arI/PvzLx9Q==",
"version": "0.4.0-238",
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua/-/aqua-0.4.0-238.tgz",
"integrity": "sha512-vSie7LinYIF+WoCz16yVduGsjLL0JO6gNBi1q0WtHHXCZiLn7d7m+gNacVrIbPrI9bwUht0U6kJd6xFKqXBUhw==",
"dev": true,
"requires": {
"@fluencelabs/fluence": "0.12.1"

View File

@ -40,7 +40,7 @@
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@fluencelabs/aqua": "^0.4.0-235",
"@fluencelabs/aqua": "^0.4.0-238",
"@fluencelabs/aqua-lib": "0.1.14",
"@types/yup": "^0.29.11",
"babel-loader": "^8.1.0",

27
src/_aqua/app.d.ts vendored
View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.4.0-235
* Aqua version: 0.4.0-238
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
@ -15,25 +15,32 @@ import {
// Services
export interface MyOpDef {
array: (i: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, s: string, callParams: CallParams<'i' | 's'>) => number | Promise<number>;
}
export function registerMyOp(service: MyOpDef): void;
export function registerMyOp(serviceId: string, service: MyOpDef): void;
export function registerMyOp(peer: FluencePeer, service: MyOpDef): void;
export function registerMyOp(peer: FluencePeer, serviceId: string, service: MyOpDef): void;
// Functions
export function collectServiceInterfaces(peer_: string, services: { blueprint_id: string; id: string; owner_id: string; }[], collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function collectServiceInterfaces(peer: FluencePeer, peer_: string, services: { blueprint_id: string; id: string; owner_id: string; }[], collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function collectServiceInterfaces(peer_: string, services: { blueprint_id: string; id: string; owner_id: string; }[], collectServiceInterface: (arg0: string, arg1: number[], callParams: CallParams<'arg0' | 'arg1'>) => void | Promise<void>, log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function collectServiceInterfaces(peer: FluencePeer, peer_: string, services: { blueprint_id: string; id: string; owner_id: string; }[], collectServiceInterface: (arg0: string, arg1: number[], callParams: CallParams<'arg0' | 'arg1'>) => void | Promise<void>, log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function askAllAndSend(peer_: string, collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function askAllAndSend(peer: FluencePeer, peer_: string, collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function askAllAndSend(peer_: string, collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: number[], callParams: CallParams<'arg0' | 'arg1'>) => void | Promise<void>, log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function askAllAndSend(peer: FluencePeer, peer_: string, collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: number[], callParams: CallParams<'arg0' | 'arg1'>) => void | Promise<void>, log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function findAndAskNeighboursSchema(relayPeerId: string, clientId: string, collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function findAndAskNeighboursSchema(peer: FluencePeer, relayPeerId: string, clientId: string, collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function findAndAskNeighboursSchema(relayPeerId: string, clientId: string, collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: number[], callParams: CallParams<'arg0' | 'arg1'>) => void | Promise<void>, log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function findAndAskNeighboursSchema(peer: FluencePeer, relayPeerId: string, clientId: string, collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: number[], callParams: CallParams<'arg0' | 'arg1'>) => void | Promise<void>, log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function getAll(knownPeers: string[], collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function getAll(peer: FluencePeer, knownPeers: string[], collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: string, arg2: { function_signatures: { arguments: string[][]; name: string; output_types: string[]; }[]; record_types: { fields: string[][]; id: number; name: string; }[]; }, callParams: CallParams<'arg0' | 'arg1' | 'arg2'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function getAll(knownPeers: string[], collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: number[], callParams: CallParams<'arg0' | 'arg1'>) => void | Promise<void>, log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;
export function getAll(peer: FluencePeer, knownPeers: string[], collectPeerInfo: (arg0: string, arg1: { external_addresses: string[]; }, arg2: { blueprint_id: string; id: string; owner_id: string; }[], arg3: { dependencies: string[]; id: string; name: string; }[], arg4: { config: { name: string; }; hash: string; name: string; }[], callParams: CallParams<'arg0' | 'arg1' | 'arg2' | 'arg3' | 'arg4'>) => void | Promise<void>, collectServiceInterface: (arg0: string, arg1: number[], callParams: CallParams<'arg0' | 'arg1'>) => void | Promise<void>, log: (arg0: string, callParams: CallParams<'arg0'>) => void | Promise<void>, config?: {ttl?: number}): Promise<void>;

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.4.0-235
* Aqua version: 0.4.0-238
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
@ -16,6 +16,39 @@ import {
// Services
export function registerMyOp(...args) {
registerService(
args,
{
"defaultServiceId" : "op",
"functions" : [
{
"functionName" : "array",
"argDefs" : [
{
"name" : "i",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "s",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "primitive"
}
}
]
}
);
}
// Functions
export function collectServiceInterfaces(...args) {
@ -25,31 +58,37 @@ export function collectServiceInterfaces(...args) {
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("getDataSrv" "peer") [] peer)
)
(call %init_peer_id% ("getDataSrv" "services") [] services)
)
(fold services srv
(par
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("getDataSrv" "peer") [] peer)
)
(call %init_peer_id% ("getDataSrv" "services") [] services)
)
(call -relay- ("op" "noop") [])
(xor
)
(xor
(fold services srv
(seq
(seq
(call peer ("srv" "get_interface") [srv.$.id!] iface)
(call -relay- ("op" "noop") [])
)
(xor
(call %init_peer_id% ("callbackSrv" "collectServiceInterface") [peer srv.$.id! iface])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
(call peer ("op" "array") [iface srv.$.id!] $ifaces)
)
(next srv)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
(seq
(call -relay- ("op" "noop") [])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(next srv)
)
(call -relay- ("op" "noop") [])
)
(xor
(call %init_peer_id% ("callbackSrv" "collectServiceInterface") [peer ifaces])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
@ -92,9 +131,22 @@ export function collectServiceInterfaces(...args) {
"argType" : {
"tag" : "primitive"
}
},
}
],
"returnType" : {
"tag" : "void"
}
}
}
},
{
"name" : "log",
"argType" : {
"tag" : "callback",
"callback" : {
"argDefs" : [
{
"name" : "arg2",
"name" : "arg0",
"argType" : {
"tag" : "primitive"
}
@ -141,46 +193,44 @@ export function askAllAndSend(...args) {
(seq
(seq
(seq
(seq
(call peer ("peer" "identify") [] ident)
(call peer ("dist" "list_blueprints") [] blueprints)
)
(call peer ("dist" "list_modules") [] modules)
(call peer ("peer" "identify") [] ident)
(call peer ("dist" "list_blueprints") [] blueprints)
)
(call peer ("srv" "list") [] services)
(call peer ("dist" "list_modules") [] modules)
)
(call -relay- ("op" "noop") [])
(call peer ("srv" "list") [] services)
)
(xor
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [peer ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "log") ["b4 collectPeerInfo"])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(null)
)
)
(call -relay- ("op" "noop") [])
)
(fold services srv
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
(call peer ("srv" "get_interface") [srv.$.id!] iface)
(call -relay- ("op" "noop") [])
)
(xor
(call %init_peer_id% ("callbackSrv" "collectServiceInterface") [peer srv.$.id! iface])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [peer ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(seq
(call -relay- ("op" "noop") [])
(next srv)
(null)
)
)
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "log") ["b4 collectServiceInterfaces"])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
)
(null)
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
@ -263,9 +313,22 @@ export function askAllAndSend(...args) {
"argType" : {
"tag" : "primitive"
}
},
}
],
"returnType" : {
"tag" : "void"
}
}
}
},
{
"name" : "log",
"argType" : {
"tag" : "callback",
"callback" : {
"argDefs" : [
{
"name" : "arg2",
"name" : "arg0",
"argType" : {
"tag" : "primitive"
}
@ -309,82 +372,101 @@ export function findAndAskNeighboursSchema(...args) {
(call -relay- ("op" "noop") [])
)
(xor
(seq
(call relayPeerId ("kad" "neighborhood") [clientId [] []] neighbors)
(fold neighbors n
(par
(xor
(par
(seq
(seq
(call -relay- ("op" "noop") [])
(call relayPeerId ("kad" "neighborhood") [clientId [] []] neighbors)
)
(call %init_peer_id% ("op" "noop") [])
)
(seq
(call -relay- ("op" "noop") [])
(fold neighbors n
(par
(seq
(call n ("kad" "neighborhood") [clientId [] []] neighbors2)
(fold neighbors2 n2
(call -relay- ("op" "noop") [])
(xor
(par
(seq
(seq
(call -relay- ("op" "noop") [])
(call n ("kad" "neighborhood") [clientId [] []] neighbors2)
)
(call %init_peer_id% ("op" "noop") [])
)
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(fold neighbors2 n2
(par
(seq
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
(seq
(seq
(call n2 ("peer" "identify") [] ident)
(call n2 ("dist" "list_blueprints") [] blueprints)
(seq
(seq
(call n2 ("peer" "identify") [] ident)
(call n2 ("dist" "list_blueprints") [] blueprints)
)
(call n2 ("dist" "list_modules") [] modules)
)
(call n2 ("srv" "list") [] services)
)
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "log") ["b4 collectPeerInfo"])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(null)
)
(call n2 ("dist" "list_modules") [] modules)
)
(call n2 ("srv" "list") [] services)
)
(call -relay- ("op" "noop") [])
)
(xor
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [n2 ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(call -relay- ("op" "noop") [])
)
(fold services srv
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(par
(seq
(call n2 ("srv" "get_interface") [srv.$.id!] iface)
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [n2 ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(null)
)
)
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "collectServiceInterface") [n2 srv.$.id! iface])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
(call %init_peer_id% ("callbackSrv" "log") ["b4 collectServiceInterfaces"])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
(null)
)
)
(seq
(call -relay- ("op" "noop") [])
(next srv)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
)
)
)
(seq
(call -relay- ("op" "noop") [])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
(seq
(call -relay- ("op" "noop") [])
(next n2)
)
)
)
)
(next n2)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
)
)
(seq
(call -relay- ("op" "noop") [])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
(next n)
)
)
(next n)
)
)
)
@ -474,9 +556,22 @@ export function findAndAskNeighboursSchema(...args) {
"argType" : {
"tag" : "primitive"
}
},
}
],
"returnType" : {
"tag" : "void"
}
}
}
},
{
"name" : "log",
"argType" : {
"tag" : "callback",
"callback" : {
"argDefs" : [
{
"name" : "arg2",
"name" : "arg0",
"argType" : {
"tag" : "primitive"
}
@ -514,12 +609,12 @@ export function getAll(...args) {
(call %init_peer_id% ("getDataSrv" "knownPeers") [] knownPeers)
)
(xor
(fold knownPeers peer
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(par
(fold knownPeers peer
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
(seq
@ -533,45 +628,46 @@ export function getAll(...args) {
)
(call peer ("srv" "list") [] services)
)
(call -relay- ("op" "noop") [])
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "log") ["b4 collectPeerInfo"])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(null)
)
)
(xor
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [peer ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [peer ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(null)
)
)
(call -relay- ("op" "noop") [])
)
(fold services srv
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
(call peer ("srv" "get_interface") [srv.$.id!] iface)
(call -relay- ("op" "noop") [])
)
(xor
(call %init_peer_id% ("callbackSrv" "collectServiceInterface") [peer srv.$.id! iface])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(call %init_peer_id% ("callbackSrv" "log") ["b4 collectServiceInterfaces"])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
)
(seq
(call -relay- ("op" "noop") [])
(next srv)
)
(null)
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
)
(next peer)
)
(next peer)
)
(null)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
)
@ -653,9 +749,22 @@ export function getAll(...args) {
"argType" : {
"tag" : "primitive"
}
},
}
],
"returnType" : {
"tag" : "void"
}
}
}
},
{
"name" : "log",
"argType" : {
"tag" : "callback",
"callback" : {
"argDefs" : [
{
"name" : "arg2",
"name" : "arg0",
"argType" : {
"tag" : "primitive"
}

View File

@ -30,8 +30,9 @@ import { askAllAndSend, getAll } from './_aqua/app';
const defaultNetworkName = 'testNet + krasnodar';
const defaultEnv = {
relays: [...testNet, ...krasnodar, ...stage],
relayIdx: 2,
//relays: [...testNet, ...krasnodar, ...stage],
relays: [krasnodar[0]],
relayIdx: 0,
logLevel: 'error',
};
@ -115,7 +116,8 @@ function genFlags(peerId, relays, relayIdx) {
const { relays, relayIdx, logLevel } = await initEnvironment();
setLogLevel(logLevel);
const keyPair = await KeyPair.randomEd25519();
await Fluence.start({ connectTo: relays[relayIdx].multiaddr });
await Fluence.start({ connectTo: relays[relayIdx].multiaddr, defaultTtlMs: 200000 });
// await Fluence.start({ connectTo: relays[relayIdx].multiaddr });
const pid = Fluence.getStatus().peerId;
const flags = genFlags(pid, relays, relayIdx);
console.log(`Own peer id: ${pid}`);
@ -128,16 +130,17 @@ function genFlags(peerId, relays, relayIdx) {
});
// alias ServiceInterfaceCb: PeerId, string, Interface -> ()
function collectServiceInterface(peer_id, service_id, iface) {
function collectServiceInterface(peer_id, ifaces) {
// console.count(`service interface from ${peer_id}`);
try {
const eventRaw = {
peer_id,
service_id,
interface: iface,
};
app.ports.collectServiceInterface.send(eventRaw);
for (var iface of ifaces) {
const eventRaw = {
peer_id,
service_id: iface[1],
interface: iface[0],
};
app.ports.collectServiceInterface.send(eventRaw);
}
} catch (err) {
log.error('Elm eventreceiver failed: ', err);
}
@ -168,7 +171,8 @@ function genFlags(peerId, relays, relayIdx) {
// });
// }
await getAll(data.knownPeers, collectPeerInfo, collectServiceInterface, { ttl: 120000 });
console.log('called getAll');
await getAll(Fluence.getPeer(), data.knownPeers, collectPeerInfo, collectServiceInterface, console.log);
});
})();