Add 'showStat', update fluenceJS & aqua (#32)

This commit is contained in:
folex 2022-02-09 21:24:22 +03:00 committed by GitHub
parent 99ce91a47c
commit f2d182c597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1116 additions and 679 deletions

1049
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
},
"homepage": "https://github.com/fluencelabs/fluence-admin#readme",
"dependencies": {
"@fluencelabs/fluence": "0.17.1",
"@fluencelabs/fluence": "0.19.0",
"@fluencelabs/fluence-network-environment": "1.0.10",
"css-spinners": "^1.0.1",
"tachyons": "^4.12.0",
@ -41,7 +41,7 @@
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@fluencelabs/aqua": "^0.5.3-260",
"@fluencelabs/aqua": "0.6.0-263",
"@fluencelabs/aqua-lib": "0.3.3",
"@types/yup": "^0.29.11",
"babel-loader": "^8.1.0",

69
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.6.0-263
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
@ -20,20 +20,71 @@ import {
// 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 askAllAndSend(
peer_: string,
collectPeerInfo: (arg0: string, arg1: { air_version: string; external_addresses: string[]; node_version: 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: { air_version: string; external_addresses: string[]; node_version: 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: 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 getAll(
knownPeers: string[],
collectPeerInfo: (arg0: string, arg1: { air_version: string; external_addresses: string[]; node_version: 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: { air_version: string; external_addresses: string[]; node_version: 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: 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: { air_version: string; external_addresses: string[]; node_version: 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: { air_version: string; external_addresses: string[]; node_version: 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: 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 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>;

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.6.0-263
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
@ -18,7 +18,7 @@ import {
// Functions
export function collectServiceInterfaces(...args) {
export function askAllAndSend(...args) {
let script = `
(xor
@ -28,12 +28,39 @@ export function collectServiceInterfaces(...args) {
(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
(seq
(seq
(seq
(seq
(seq
(seq
(seq
(call peer ("peer" "identify") [] ident)
(call peer ("dist" "list_blueprints") [] blueprints)
)
(call peer ("dist" "list_modules") [] modules)
)
(call peer ("srv" "list") [] services)
)
(call -relay- ("op" "noop") [])
)
(xor
(seq
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [peer ident services blueprints modules])
(call -relay- ("op" "noop") [])
)
(seq
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
(call -relay- ("op" "noop") [])
)
)
)
(par
(fold services srv
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
@ -42,23 +69,32 @@ export function collectServiceInterfaces(...args) {
)
(xor
(call %init_peer_id% ("callbackSrv" "collectServiceInterface") [peer srv.$.id! iface])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
(next srv)
)
)
(null)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
(call -relay- ("op" "noop") [])
)
(seq
(call -relay- ("op" "noop") [])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
)
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
)
`
return callFunction(
args,
{
"functionName" : "collectServiceInterfaces",
"functionName" : "askAllAndSend",
"returnType" : {
"tag" : "void"
},
@ -70,11 +106,48 @@ export function collectServiceInterfaces(...args) {
}
},
{
"name" : "services",
"name" : "collectPeerInfo",
"argType" : {
"tag" : "callback",
"callback" : {
"argDefs" : [
{
"name" : "arg0",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "arg1",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "arg2",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "arg3",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "arg4",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "void"
}
}
}
},
{
"name" : "collectServiceInterface",
"argType" : {
@ -122,7 +195,7 @@ export function collectServiceInterfaces(...args) {
}
export function askAllAndSend(...args) {
export function getAll(...args) {
let script = `
(xor
@ -130,12 +203,15 @@ export function askAllAndSend(...args) {
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("getDataSrv" "peer") [] peer)
(call %init_peer_id% ("getDataSrv" "knownPeers") [] knownPeers)
)
(call -relay- ("op" "noop") [])
)
(xor
(seq
(par
(fold knownPeers peer
(par
(xor
(seq
(seq
(seq
@ -152,16 +228,19 @@ export function askAllAndSend(...args) {
(call -relay- ("op" "noop") [])
)
(xor
(seq
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [peer ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(call -relay- ("op" "noop") [])
)
(seq
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
(call -relay- ("op" "noop") [])
)
)
)
(par
(fold services srv
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
@ -175,30 +254,38 @@ export function askAllAndSend(...args) {
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
)
(seq
(call -relay- ("op" "noop") [])
(next srv)
)
)
(null)
)
)
(seq
(call -relay- ("op" "noop") [])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
)
)
(next peer)
)
)
(null)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 6])
)
`
return callFunction(
args,
{
"functionName" : "askAllAndSend",
"functionName" : "getAll",
"returnType" : {
"tag" : "void"
},
"argDefs" : [
{
"name" : "peer",
"name" : "knownPeers",
"argType" : {
"tag" : "primitive"
}
@ -309,13 +396,16 @@ export function findAndAskNeighboursSchema(...args) {
(call -relay- ("op" "noop") [])
)
(xor
(seq
(seq
(call relayPeerId ("kad" "neighborhood") [clientId [] []] neighbors)
(par
(fold neighbors n
(par
(xor
(seq
(call n ("kad" "neighborhood") [clientId [] []] neighbors2)
(par
(fold neighbors2 n2
(par
(seq
@ -325,7 +415,6 @@ export function findAndAskNeighboursSchema(...args) {
(seq
(seq
(seq
(seq
(seq
(seq
(call n2 ("peer" "identify") [] ident)
@ -338,16 +427,19 @@ export function findAndAskNeighboursSchema(...args) {
(call -relay- ("op" "noop") [])
)
(xor
(seq
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [n2 ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(call -relay- ("op" "noop") [])
)
(seq
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
(call -relay- ("op" "noop") [])
)
)
)
(par
(fold services srv
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
@ -361,12 +453,10 @@ export function findAndAskNeighboursSchema(...args) {
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
)
(seq
(call -relay- ("op" "noop") [])
(next srv)
)
)
(null)
)
)
(seq
@ -378,6 +468,8 @@ export function findAndAskNeighboursSchema(...args) {
(next n2)
)
)
(null)
)
)
(seq
(call -relay- ("op" "noop") [])
@ -387,10 +479,17 @@ export function findAndAskNeighboursSchema(...args) {
(next n)
)
)
(null)
)
)
(call -relay- ("op" "noop") [])
)
(seq
(call -relay- ("op" "noop") [])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 6])
)
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 7])
)
`
@ -504,44 +603,19 @@ export function findAndAskNeighboursSchema(...args) {
}
export function getAll(...args) {
export function collectServiceInterfaces(...args) {
let script = `
(xor
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("getDataSrv" "knownPeers") [] knownPeers)
(call %init_peer_id% ("getDataSrv" "peer") [] peer)
)
(call %init_peer_id% ("getDataSrv" "services") [] services)
)
(xor
(fold knownPeers peer
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
(seq
(seq
(seq
(seq
(seq
(call peer ("peer" "identify") [] ident)
(call peer ("dist" "list_blueprints") [] blueprints)
)
(call peer ("dist" "list_modules") [] modules)
)
(call peer ("srv" "list") [] services)
)
(call -relay- ("op" "noop") [])
)
(xor
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [peer ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(call -relay- ("op" "noop") [])
)
(fold services srv
(par
(seq
@ -554,88 +628,41 @@ export function getAll(...args) {
)
(xor
(call %init_peer_id% ("callbackSrv" "collectServiceInterface") [peer srv.$.id! iface])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(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])
)
)
(next peer)
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 6])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
`
return callFunction(
args,
{
"functionName" : "getAll",
"functionName" : "collectServiceInterfaces",
"returnType" : {
"tag" : "void"
},
"argDefs" : [
{
"name" : "knownPeers",
"name" : "peer",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "collectPeerInfo",
"argType" : {
"tag" : "callback",
"callback" : {
"argDefs" : [
{
"name" : "arg0",
"name" : "services",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "arg1",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "arg2",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "arg3",
"argType" : {
"tag" : "primitive"
}
},
{
"name" : "arg4",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "void"
}
}
}
},
{
"name" : "collectServiceInterface",
"argType" : {

View File

@ -127,6 +127,118 @@ function genFlags(peerId, relays, relayIdx) {
flags: flags,
});
if (window) {
window.collectedData = {
// service ids
services: new Map(),
// services per creator
creators: new Map(),
// blueprints used in services
serviceBlueprints: new Set(),
// all blueprints
blueprints: new Map(),
// module hashes used in services
serviceModules: new Set(),
// unique module names used in services
moduleNames: new Set(),
// all modules
modules: new Map(),
// peer infos per PeerId
peerInfos: new Map(),
};
window.showStat = () => {
/*
1490 users created 3018 services
from 280 blueprints
from 299 modules of which there are 43 unique module names
*/
let usersCount = window.collectedData.creators.size;
let serviceCount = window.collectedData.services.size;
let blueprintCount = window.collectedData.serviceBlueprints.size;
let moduleCount = window.collectedData.serviceModules.size;
let nameCount = window.collectedData.moduleNames.size;
let totalModules = window.collectedData.modules.size;
console.log(`${usersCount} users created ${serviceCount} services`);
console.log(`from ${blueprintCount} blueprints`);
console.log(`from ${moduleCount} modules of which there are ${nameCount} unique module names`);
console.log(`total ${totalModules} modules were uploaded`);
let servicesPerHost = new Map();
for (let service of window.collectedData.services.values()) {
let perHost = servicesPerHost.has(service.host) ? servicesPerHost.get(service.host) : new Set();
perHost.add(service.id);
servicesPerHost.set(service.host, perHost);
}
let N = 10;
let sorted = [...servicesPerHost.entries()].sort((a, b) => b[1].size - a[1].size);
console.log(`top ${N} nodes by hosted services:`)
let slice = sorted.slice(0, 10);
for (let entry of slice) {
console.log(`\t node ${entry[0]} has ${entry[1].size} services`);
}
let byNodeVersion = new Map();
let byAirVersion = new Map();
for (let info of window.collectedData.peerInfos.values()) {
let byNodeCount = byNodeVersion.get(info.node_version) || 0;
byNodeVersion.set(info.node_version, byNodeCount + 1)
let byAirCount = byAirVersion.get(info.air_version) || 0;
byAirVersion.set(info.air_version, byAirCount + 1)
}
console.log("Nodes version distribution:");
for (let entry of byNodeVersion.entries()) {
let version = entry[0];
let count = entry[1];
console.log(`\t${version}: ${count} nodes`);
}
console.log("AIR intepreter versions distribution:");
for (let entry of byAirVersion.entries()) {
let version = entry[0];
let count = entry[1];
console.log(`\t${version}: ${count} nodes`);
}
};
}
function collectStats(peerId, identify, services, blueprints, modules) {
if (window) {
window.collectedData.peerInfos.set(peerId, identify);
for (let blueprint of blueprints) {
window.collectedData.blueprints.set(blueprint.id, blueprint);
}
for (let module of modules) {
window.collectedData.modules.set(module.hash, module);
}
for (let service of services) {
service.host = peerId;
window.collectedData.services.set(service.id, service);
window.collectedData.serviceBlueprints.add(service.blueprint_id);
let blueprint = window.collectedData.blueprints.get(service.blueprint_id);
for (let prefixedHash of blueprint.dependencies) {
let moduleHash = prefixedHash.split(':')[1];
window.collectedData.serviceModules.add(moduleHash);
let module = window.collectedData.modules.get(moduleHash);
window.collectedData.moduleNames.add(module.name);
}
let perCreator = window.collectedData.creators.has(service.owner_id) ? window.collectedData.creators.get(service.owner_id) : new Set();
perCreator.add(service.id);
window.collectedData.creators.set(service.owner_id, perCreator);
}
}
}
// alias ServiceInterfaceCb: PeerId, string, Interface -> ()
function collectServiceInterface(peer_id, service_id, iface) {
// console.count(`service interface from ${peer_id}`);
@ -147,6 +259,8 @@ function genFlags(peerId, relays, relayIdx) {
function collectPeerInfo(peerId, identify, services, blueprints, modules, interfaces) {
// console.log('peer info from %s, %s services', peerId, services.length);
try {
collectStats(peerId, identify, services, blueprints, modules);
const eventRaw = {
// HACK: show AIR interpreter version in the NODE ID field
peerId: peerId + ' (' + identify.air_version + ')',