mirror of
https://github.com/fluencelabs/dashboard
synced 2024-12-04 15:20:21 +00:00
Migrate air code to aqua (#13)
* Migrate air code to aqua * Replace TypeScript with JavaScript which enables elm livereload
This commit is contained in:
parent
d7a59b2ff0
commit
0b3d7c47c1
31
aqua/app.aqua
Normal file
31
aqua/app.aqua
Normal file
@ -0,0 +1,31 @@
|
||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
|
||||
service DashboardEvent("event"):
|
||||
peers_discovered()
|
||||
all_info(peer: PeerId, ident: Info, services: []Service, blueprints: []Blueprint, modules: []Module)
|
||||
|
||||
func askAllAndSend(peer: PeerId):
|
||||
on peer:
|
||||
ident <- Peer.identify()
|
||||
blueprints <- Dist.list_blueprints()
|
||||
modules <- Dist.list_modules()
|
||||
services <- Srv.list()
|
||||
DashboardEvent.all_info(peer, ident, services, blueprints, modules)
|
||||
|
||||
func findAndAskNeighboursSchema(relayPeerId: PeerId, clientId: PeerId):
|
||||
on relayPeerId:
|
||||
neighbors <- Kademlia.neighborhood(clientId, false)
|
||||
for n <- neighbors par:
|
||||
on n:
|
||||
neighbors2 <- Kademlia.neighborhood(clientId, false)
|
||||
for n2 <- neighbors2:
|
||||
askAllAndSend(n2)
|
||||
|
||||
func getAll(relayPeerId: PeerId, knownPeers: []PeerId):
|
||||
askAllAndSend(relayPeerId)
|
||||
|
||||
par for peer <- knownPeers par:
|
||||
askAllAndSend(peer)
|
||||
|
||||
par findAndAskNeighboursSchema(relayPeerId, %init_peer_id%)
|
||||
|
273
package-lock.json
generated
273
package-lock.json
generated
@ -997,6 +997,18 @@
|
||||
"to-fast-properties": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"@fluencelabs/aqua-cli": {
|
||||
"version": "0.1.5-142",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-cli/-/aqua-cli-0.1.5-142.tgz",
|
||||
"integrity": "sha512-22BhF9j44FPTUc3JM6tGRz0SnyMthJM05cIuS98mHYTTTPU7i0jOS0dl/V7BYzSBJBAwEmZLA1Z/3bGr9PUBEA==",
|
||||
"dev": true
|
||||
},
|
||||
"@fluencelabs/aqua-lib": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/aqua-lib/-/aqua-lib-0.1.5.tgz",
|
||||
"integrity": "sha512-0f5Lo9NT4ZvN+S/oGYiNxLUtpZsTfDy2qL0D4SFPVoj2+YPPK2PKSzZnja2clfM1KHHP6kT6Jd20sHVBIxBMtw==",
|
||||
"dev": true
|
||||
},
|
||||
"@fluencelabs/avm": {
|
||||
"version": "0.9.12",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.9.12.tgz",
|
||||
@ -2859,6 +2871,232 @@
|
||||
"upath": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"chokidar-cli": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/chokidar-cli/-/chokidar-cli-2.1.0.tgz",
|
||||
"integrity": "sha512-6n21AVpW6ywuEPoxJcLXMA2p4T+SLjWsXKny/9yTWFz0kKxESI3eUylpeV97LylING/27T/RVTY0f2/0QaWq9Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chokidar": "^3.2.3",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"lodash.throttle": "^4.1.1",
|
||||
"yargs": "^13.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"anymatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
|
||||
"integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"normalize-path": "^3.0.0",
|
||||
"picomatch": "^2.0.4"
|
||||
}
|
||||
},
|
||||
"binary-extensions": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
|
||||
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
||||
"dev": true
|
||||
},
|
||||
"braces": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fill-range": "^7.0.1"
|
||||
}
|
||||
},
|
||||
"chokidar": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz",
|
||||
"integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"anymatch": "~3.1.1",
|
||||
"braces": "~3.0.2",
|
||||
"fsevents": "~2.3.1",
|
||||
"glob-parent": "~5.1.0",
|
||||
"is-binary-path": "~2.1.0",
|
||||
"is-glob": "~4.0.1",
|
||||
"normalize-path": "~3.0.0",
|
||||
"readdirp": "~3.5.0"
|
||||
}
|
||||
},
|
||||
"cliui": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
|
||||
"integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"string-width": "^3.1.0",
|
||||
"strip-ansi": "^5.2.0",
|
||||
"wrap-ansi": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"to-regex-range": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"find-up": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
|
||||
"integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"locate-path": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"get-caller-file": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
|
||||
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||
"dev": true
|
||||
},
|
||||
"glob-parent": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-glob": "^4.0.1"
|
||||
}
|
||||
},
|
||||
"is-binary-path": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
|
||||
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"binary-extensions": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
|
||||
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
|
||||
"dev": true
|
||||
},
|
||||
"is-number": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||
"dev": true
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
|
||||
"integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-locate": "^3.0.0",
|
||||
"path-exists": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"p-locate": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
|
||||
"integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"p-limit": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"readdirp": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz",
|
||||
"integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"picomatch": "^2.2.1"
|
||||
}
|
||||
},
|
||||
"require-main-filename": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
|
||||
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
|
||||
"dev": true
|
||||
},
|
||||
"string-width": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
|
||||
"integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"emoji-regex": "^7.0.1",
|
||||
"is-fullwidth-code-point": "^2.0.0",
|
||||
"strip-ansi": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-number": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"which-module": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
|
||||
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",
|
||||
"dev": true
|
||||
},
|
||||
"wrap-ansi": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
|
||||
"integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^3.2.0",
|
||||
"string-width": "^3.0.0",
|
||||
"strip-ansi": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"yargs": {
|
||||
"version": "13.3.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz",
|
||||
"integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cliui": "^5.0.0",
|
||||
"find-up": "^3.0.0",
|
||||
"get-caller-file": "^2.0.1",
|
||||
"require-directory": "^2.1.1",
|
||||
"require-main-filename": "^2.0.0",
|
||||
"set-blocking": "^2.0.0",
|
||||
"string-width": "^3.0.0",
|
||||
"which-module": "^2.0.0",
|
||||
"y18n": "^4.0.0",
|
||||
"yargs-parser": "^13.1.2"
|
||||
}
|
||||
},
|
||||
"yargs-parser": {
|
||||
"version": "13.1.2",
|
||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
|
||||
"integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"camelcase": "^5.0.0",
|
||||
"decamelize": "^1.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"chownr": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
|
||||
@ -4889,6 +5127,12 @@
|
||||
"binwrap": "0.2.2"
|
||||
}
|
||||
},
|
||||
"emoji-regex": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
|
||||
"integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==",
|
||||
"dev": true
|
||||
},
|
||||
"emojis-list": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz",
|
||||
@ -8415,6 +8659,12 @@
|
||||
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz",
|
||||
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="
|
||||
},
|
||||
"lodash.debounce": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
|
||||
"integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=",
|
||||
"dev": true
|
||||
},
|
||||
"lodash.find": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.find/-/lodash.find-4.6.0.tgz",
|
||||
@ -8451,6 +8701,12 @@
|
||||
"resolved": "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-4.1.0.tgz",
|
||||
"integrity": "sha1-/H3oEx2MisB+S0n3T/6CnR8r7EQ="
|
||||
},
|
||||
"lodash.throttle": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",
|
||||
"integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=",
|
||||
"dev": true
|
||||
},
|
||||
"lodash.uniq": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
|
||||
@ -13091,6 +13347,23 @@
|
||||
"safe-buffer": "~5.2.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
||||
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^4.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
|
||||
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"strip-bom": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
|
||||
|
15
package.json
15
package.json
@ -9,7 +9,15 @@
|
||||
"dev": "webpack-dev-server --hot --colors --port 3000",
|
||||
"build": "webpack",
|
||||
"prod": "webpack -p",
|
||||
"analyse": "elm-analyse -s -p 3001 -o"
|
||||
"analyse": "elm-analyse -s -p 3001 -o",
|
||||
"compile-aqua": "aqua-cli --js -i ./aqua/ -o ./src/_aqua",
|
||||
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"watch": [
|
||||
"aqua"
|
||||
],
|
||||
"ext": "aqua"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -31,8 +39,11 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/preset-env": "^7.11.5",
|
||||
"@fluencelabs/aqua-cli": "^0.1.5-142",
|
||||
"@fluencelabs/aqua-lib": "^0.1.5",
|
||||
"@types/yup": "^0.29.11",
|
||||
"babel-loader": "^8.1.0",
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"closure-webpack-plugin": "^2.3.0",
|
||||
"copy-webpack-plugin": "^6.4.1",
|
||||
@ -50,8 +61,8 @@
|
||||
"node-sass": "^4.14.1",
|
||||
"optimize-css-assets-webpack-plugin": "^5.0.4",
|
||||
"resolve-url-loader": "^3.1.1",
|
||||
"source-map-loader": "^1.0.0",
|
||||
"sass-loader": "^10.0.2",
|
||||
"source-map-loader": "^1.0.0",
|
||||
"style-loader": "^1.2.1",
|
||||
"url-loader": "^4.1.0",
|
||||
"webpack": "^4.44.2",
|
||||
|
81
src/Air.elm
81
src/Air.elm
@ -1,81 +0,0 @@
|
||||
module Air exposing (..)
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Json.Encode exposing (Value)
|
||||
|
||||
|
||||
type Air
|
||||
= Air (Dict String Value) String
|
||||
|
||||
|
||||
call : String -> String -> List String -> Maybe String -> Air
|
||||
call peerPart fnPart args res =
|
||||
let
|
||||
captureResult =
|
||||
case res of
|
||||
Just n ->
|
||||
" " ++ n
|
||||
|
||||
Nothing ->
|
||||
""
|
||||
in
|
||||
Air Dict.empty ("(call " ++ peerPart ++ " " ++ fnPart ++ " [" ++ String.join " " args ++ "]" ++ captureResult ++ ")\n")
|
||||
|
||||
|
||||
callBI : String -> ( String, String ) -> List String -> Maybe String -> Air
|
||||
callBI p ( s, f ) args cap =
|
||||
call p ("(\"" ++ s ++ "\" \"" ++ f ++ "\")") args cap
|
||||
|
||||
|
||||
event : String -> List String -> Air
|
||||
event name args =
|
||||
callBI "%init_peer_id%" ( "event", name ) args Nothing
|
||||
|
||||
|
||||
combine : String -> Air -> Air -> Air
|
||||
combine combName (Air ld ls) (Air rd rs) =
|
||||
Air (Dict.union ld rd) ("(" ++ combName ++ "\n " ++ ls ++ "\n " ++ rs ++ ")\n")
|
||||
|
||||
|
||||
seq =
|
||||
combine "seq"
|
||||
|
||||
|
||||
par =
|
||||
combine "par"
|
||||
|
||||
|
||||
xor =
|
||||
combine "xor"
|
||||
|
||||
|
||||
fold : String -> String -> Air -> Air
|
||||
fold iter item (Air d s) =
|
||||
Air d ("(fold " ++ iter ++ " " ++ item ++ "\n" ++ s ++ ")\n")
|
||||
|
||||
|
||||
flattenOp : String -> String
|
||||
flattenOp s =
|
||||
s ++ "!"
|
||||
|
||||
|
||||
next : String -> Air
|
||||
next item =
|
||||
Air Dict.empty ("(next " ++ item ++ ")\n")
|
||||
|
||||
|
||||
set : String -> Value -> Air -> Air
|
||||
set name value (Air d s) =
|
||||
Air (Dict.insert name value d) s
|
||||
|
||||
|
||||
|
||||
-- Assumes that relay's id is set to relayId: moves execution to init peer, executes here
|
||||
|
||||
|
||||
relayEvent : String -> List String -> Air
|
||||
relayEvent name args =
|
||||
seq
|
||||
(callBI "relayId" ( "op", "identity" ) [] Nothing)
|
||||
<|
|
||||
event name args
|
@ -1,31 +0,0 @@
|
||||
module AirScripts.CallPeers exposing (..)
|
||||
|
||||
import Air exposing (Air, callBI, flattenOp, fold, next, par, relayEvent, seq, set)
|
||||
import Json.Encode exposing (list, string)
|
||||
|
||||
|
||||
air : String -> String -> ( String, String, String ) -> List String -> Air
|
||||
air peerId relayId ( event, service, fnName ) peers =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| string relayId
|
||||
|
||||
peersSet =
|
||||
set "peers" <| list string peers
|
||||
|
||||
airScript =
|
||||
seq
|
||||
(callBI "relayId" ( "op", "identity" ) [] Nothing)
|
||||
(fold "peers" "p" <|
|
||||
par
|
||||
(seq
|
||||
(callBI "p" ( service, fnName ) [] (Just "result"))
|
||||
(relayEvent event [ "p", "result" ])
|
||||
)
|
||||
(next "p")
|
||||
)
|
||||
in
|
||||
clientIdSet <| relayIdSet <| peersSet <| airScript
|
@ -1,31 +0,0 @@
|
||||
module AirScripts.DiscoverPeers exposing (..)
|
||||
|
||||
import Air exposing (Air, callBI, flattenOp, fold, next, par, relayEvent, seq, set)
|
||||
import Json.Encode as Encode
|
||||
|
||||
|
||||
air : String -> String -> Air
|
||||
air peerId relayId =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| Encode.string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| Encode.string relayId
|
||||
|
||||
airScript =
|
||||
seq
|
||||
(callBI "relayId" ( "kad", "neighborhood" ) [ "clientId" ] (Just "peers"))
|
||||
(par
|
||||
(relayEvent "peers_discovered" [ "relayId", "peers" ])
|
||||
(fold "peers" "p" <|
|
||||
par
|
||||
(seq
|
||||
(callBI "p" ( "kad", "neighborhood" ) [ "clientId" ] (Just "morePeers"))
|
||||
(relayEvent "peers_discovered" [ "p", "morePeers" ])
|
||||
)
|
||||
(next "p")
|
||||
)
|
||||
)
|
||||
in
|
||||
relayIdSet <| clientIdSet <| airScript
|
@ -1,128 +0,0 @@
|
||||
module AirScripts.GetAll exposing (..)
|
||||
|
||||
import Air exposing (Air, callBI, flattenOp, fold, next, par, relayEvent, seq, set)
|
||||
import Json.Encode exposing (list, string)
|
||||
|
||||
|
||||
askRelaySchema : Air
|
||||
askRelaySchema =
|
||||
seq
|
||||
(callBI "relayId" ( "op", "identity" ) [] Nothing)
|
||||
(askAllAndSend "relayId")
|
||||
|
||||
|
||||
askRelayScript : String -> String -> Air
|
||||
askRelayScript peerId relayId =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| string relayId
|
||||
in
|
||||
clientIdSet <| relayIdSet <| askRelaySchema
|
||||
|
||||
|
||||
askPeersSchema : Air
|
||||
askPeersSchema =
|
||||
fold "knownPeers" "p" <|
|
||||
par
|
||||
(seq
|
||||
(callBI "p" ( "op", "identity" ) [] Nothing)
|
||||
(askAllAndSend "p")
|
||||
)
|
||||
(next "p")
|
||||
|
||||
|
||||
askPeersScript : String -> String -> List String -> Air
|
||||
askPeersScript peerId relayId peers =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| string relayId
|
||||
|
||||
peersSet =
|
||||
set "knownPeers" <| list string peers
|
||||
in
|
||||
clientIdSet <| relayIdSet <| peersSet <| askPeersSchema
|
||||
|
||||
|
||||
findAndAskNeighboursSchema : Air
|
||||
findAndAskNeighboursSchema =
|
||||
seq
|
||||
(callBI "relayId" ( "op", "identity" ) [] Nothing)
|
||||
(seq
|
||||
(callBI "relayId" ( "kad", "neighborhood" ) [ "clientId" ] (Just "neigh"))
|
||||
(fold "neigh" "n" <|
|
||||
par
|
||||
(seq
|
||||
(callBI "n" ( "kad", "neighborhood" ) [ "clientId" ] (Just "moreNeigh"))
|
||||
(fold "moreNeigh" "mp" <|
|
||||
par
|
||||
(askAllAndSend "mp")
|
||||
(next "mp")
|
||||
)
|
||||
)
|
||||
(next "n")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
findAndAskNeighboursScript : String -> String -> Air
|
||||
findAndAskNeighboursScript peerId relayId =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| string relayId
|
||||
in
|
||||
clientIdSet <| relayIdSet <| findAndAskNeighboursSchema
|
||||
|
||||
|
||||
air : String -> String -> List String -> Air
|
||||
air peerId relayId peers =
|
||||
let
|
||||
clientIdSet =
|
||||
set "clientId" <| string peerId
|
||||
|
||||
relayIdSet =
|
||||
set "relayId" <| string relayId
|
||||
|
||||
peersSet =
|
||||
set "knownPeers" <| list string peers
|
||||
|
||||
askRelay =
|
||||
\innerAir ->
|
||||
seq
|
||||
(callBI "relayId" ( "op", "identity" ) [] Nothing)
|
||||
(par
|
||||
askRelaySchema
|
||||
innerAir
|
||||
)
|
||||
|
||||
askPeers =
|
||||
\innerAir ->
|
||||
par
|
||||
askPeersSchema
|
||||
innerAir
|
||||
in
|
||||
clientIdSet <| relayIdSet <| peersSet <| (askRelay <| askPeers <| findAndAskNeighboursSchema)
|
||||
|
||||
|
||||
askAllAndSend : String -> Air
|
||||
askAllAndSend var =
|
||||
seq
|
||||
(callBI var ( "peer", "identify" ) [] (Just "ident"))
|
||||
(seq
|
||||
(callBI var ( "dist", "list_blueprints" ) [] (Just "blueprints"))
|
||||
(seq
|
||||
(callBI var ( "dist", "list_modules" ) [] (Just "modules"))
|
||||
(seq
|
||||
(callBI var ( "srv", "list" ) [] (Just "services"))
|
||||
(relayEvent "all_info" [ var, "ident", "services", "blueprints", "modules" ])
|
||||
)
|
||||
)
|
||||
)
|
@ -1,9 +0,0 @@
|
||||
module Blueprints.Air exposing (..)
|
||||
|
||||
import Air exposing (Air)
|
||||
import AirScripts.CallPeers
|
||||
|
||||
|
||||
air : String -> String -> List String -> Air
|
||||
air peerId relayId peers =
|
||||
AirScripts.CallPeers.air peerId relayId ( "blueprints_discovered", "dist", "list_blueprints" ) peers
|
@ -1,9 +0,0 @@
|
||||
module Modules.Air exposing (..)
|
||||
|
||||
import Air exposing (Air)
|
||||
import AirScripts.CallPeers
|
||||
|
||||
|
||||
air : String -> String -> List String -> Air
|
||||
air peerId relayId peers =
|
||||
AirScripts.CallPeers.air peerId relayId ( "modules_discovered", "dist", "list_modules" ) peers
|
@ -1,9 +0,0 @@
|
||||
module Nodes.Air exposing (..)
|
||||
|
||||
import Air exposing (Air)
|
||||
import AirScripts.CallPeers
|
||||
|
||||
|
||||
air : String -> String -> List String -> Air
|
||||
air peerId relayId peers =
|
||||
AirScripts.CallPeers.air peerId relayId ( "peer_identity", "peer", "identify" ) peers
|
22
src/Port.elm
22
src/Port.elm
@ -1,6 +1,5 @@
|
||||
port module Port exposing (..)
|
||||
|
||||
import Air exposing (Air(..))
|
||||
import Blueprints.Model exposing (Blueprint)
|
||||
import Dict exposing (Dict)
|
||||
import Json.Encode exposing (Value)
|
||||
@ -9,27 +8,20 @@ import Nodes.Model exposing (Identify)
|
||||
import Service.Model exposing (Service)
|
||||
|
||||
|
||||
type alias SendParticle =
|
||||
{ script : String, data : Value }
|
||||
|
||||
|
||||
type alias ReceiveEvent =
|
||||
{ name : String, peer : String, peers : Maybe (List String), identify : Maybe Identify, services : Maybe (List Service), modules : Maybe (List Module), blueprints : Maybe (List Blueprint) }
|
||||
|
||||
|
||||
port sendParticle : SendParticle -> Cmd msg
|
||||
|
||||
|
||||
port eventReceiver : (ReceiveEvent -> msg) -> Sub msg
|
||||
|
||||
|
||||
port relayChanged : (String -> msg) -> Sub msg
|
||||
|
||||
|
||||
sendAir : Air -> Cmd msg
|
||||
sendAir (Air dataDict script) =
|
||||
let
|
||||
data =
|
||||
Json.Encode.object <| Dict.toList dataDict
|
||||
in
|
||||
sendParticle { script = script, data = data }
|
||||
type alias GetAll =
|
||||
{ relayPeerId : String
|
||||
, knownPeers : List String
|
||||
}
|
||||
|
||||
|
||||
port getAll : GetAll -> Cmd msg
|
||||
|
@ -1,6 +1,5 @@
|
||||
module Route exposing (..)
|
||||
|
||||
import AirScripts.GetAll as GetAll
|
||||
import BlueprintPage.View as BlueprintPage
|
||||
import Html exposing (Html, text)
|
||||
import HubPage.View as HubPage
|
||||
@ -8,7 +7,7 @@ import Model exposing (Model, Route(..))
|
||||
import ModulePage.View as ModulePage
|
||||
import Msg exposing (Msg)
|
||||
import NodePage.View as NodePage
|
||||
import Port exposing (sendAir)
|
||||
import Port exposing (getAll)
|
||||
import Url.Parser exposing ((</>), Parser, map, oneOf, s, string)
|
||||
|
||||
|
||||
@ -56,7 +55,7 @@ routeView model route =
|
||||
getAllCmd : String -> String -> List String -> Cmd msg
|
||||
getAllCmd peerId relayId knownPeers =
|
||||
Cmd.batch
|
||||
[ sendAir (GetAll.air peerId relayId knownPeers)
|
||||
[ getAll { relayPeerId = relayId, knownPeers = knownPeers }
|
||||
]
|
||||
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
module Service.Air exposing (..)
|
||||
|
||||
import Air exposing (Air)
|
||||
import AirScripts.CallPeers
|
||||
|
||||
|
||||
air : String -> String -> List String -> Air
|
||||
air peerId relayId peers =
|
||||
AirScripts.CallPeers.air peerId relayId ( "services_discovered", "srv", "list" ) peers
|
@ -16,7 +16,6 @@ limitations under the License.
|
||||
|
||||
-}
|
||||
|
||||
import AirScripts.GetAll as GetAll
|
||||
import Blueprints.Model exposing (Blueprint)
|
||||
import Browser
|
||||
import Browser.Navigation as Nav
|
||||
@ -26,7 +25,7 @@ import Model exposing (Model, PeerData, emptyPeerData)
|
||||
import Modules.Model exposing (Module)
|
||||
import Msg exposing (..)
|
||||
import Nodes.Model exposing (Identify)
|
||||
import Port exposing (sendAir)
|
||||
import Port exposing (getAll)
|
||||
import Route exposing (getAllCmd)
|
||||
import Service.Model exposing (Service)
|
||||
import Url
|
||||
@ -105,7 +104,7 @@ update msg model =
|
||||
( { model | relayId = relayId }, Cmd.none )
|
||||
|
||||
Reload ->
|
||||
( model, sendAir (GetAll.air model.peerId model.relayId model.knownPeers) )
|
||||
( model, getAll { relayPeerId = model.relayId, knownPeers = model.knownPeers } )
|
||||
|
||||
|
||||
updateModel : Model -> String -> Identify -> List Service -> List Module -> List Blueprint -> Model
|
||||
|
367
src/_aqua/app.js
Normal file
367
src/_aqua/app.js
Normal file
@ -0,0 +1,367 @@
|
||||
/**
|
||||
*
|
||||
* 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.1.5-142
|
||||
*
|
||||
*/
|
||||
import { RequestFlowBuilder } from '@fluencelabs/fluence/dist/api.unstable';
|
||||
|
||||
|
||||
|
||||
export async function askAllAndSend(client, peer) {
|
||||
let request;
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
request = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "peer") [] peer)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(xor
|
||||
(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)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(call %init_peer_id% ("event" "all_info") [peer ident services blueprints modules])
|
||||
)
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return client.relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'peer', () => {return peer;});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
// assuming error is the single argument
|
||||
const [err] = args;
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for askAllAndSend');
|
||||
})
|
||||
.build();
|
||||
});
|
||||
await client.initiateFlow(request);
|
||||
return Promise.race([promise, Promise.resolve()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function findAndAskNeighboursSchema(client, relayPeerId, clientId) {
|
||||
let request;
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
request = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "relayPeerId") [] relayPeerId)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "clientId") [] clientId)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(xor
|
||||
(seq
|
||||
(call relayPeerId ("kad" "neighborhood") [clientId false] neighbors)
|
||||
(fold neighbors n
|
||||
(par
|
||||
(xor
|
||||
(seq
|
||||
(call n ("kad" "neighborhood") [clientId false] neighbors2)
|
||||
(fold neighbors2 n2
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call n2 ("peer" "identify") [] ident)
|
||||
(call n2 ("dist" "list_blueprints") [] blueprints)
|
||||
)
|
||||
(call n2 ("dist" "list_modules") [] modules)
|
||||
)
|
||||
(call n2 ("srv" "list") [] services)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(call n ("event" "all_info") [n2 ident services blueprints modules])
|
||||
)
|
||||
(next n2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(next n)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(call %init_peer_id% ("op" "identity") [])
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return client.relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'relayPeerId', () => {return relayPeerId;});
|
||||
h.on('getDataSrv', 'clientId', () => {return clientId;});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
// assuming error is the single argument
|
||||
const [err] = args;
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for findAndAskNeighboursSchema');
|
||||
})
|
||||
.build();
|
||||
});
|
||||
await client.initiateFlow(request);
|
||||
return Promise.race([promise, Promise.resolve()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function getAll(client, relayPeerId, knownPeers) {
|
||||
let request;
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
request = new RequestFlowBuilder()
|
||||
.disableInjections()
|
||||
.withRawScript(
|
||||
`
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "relayPeerId") [] relayPeerId)
|
||||
)
|
||||
(call %init_peer_id% ("getDataSrv" "knownPeers") [] knownPeers)
|
||||
)
|
||||
(par
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call relayPeerId ("peer" "identify") [] ident)
|
||||
(call relayPeerId ("dist" "list_blueprints") [] blueprints)
|
||||
)
|
||||
(call relayPeerId ("dist" "list_modules") [] modules)
|
||||
)
|
||||
(call relayPeerId ("srv" "list") [] services)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(call %init_peer_id% ("event" "all_info") [relayPeerId ident services blueprints modules])
|
||||
)
|
||||
(fold knownPeers peer
|
||||
(par
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call peer ("peer" "identify") [] ident0)
|
||||
(call peer ("dist" "list_blueprints") [] blueprints0)
|
||||
)
|
||||
(call peer ("dist" "list_modules") [] modules0)
|
||||
)
|
||||
(call peer ("srv" "list") [] services0)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(call %init_peer_id% ("event" "all_info") [peer ident0 services0 blueprints0 modules0])
|
||||
)
|
||||
(next peer)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(xor
|
||||
(seq
|
||||
(call relayPeerId ("kad" "neighborhood") [%init_peer_id% false] neighbors)
|
||||
(fold neighbors n
|
||||
(par
|
||||
(xor
|
||||
(seq
|
||||
(call n ("kad" "neighborhood") [%init_peer_id% false] neighbors2)
|
||||
(fold neighbors2 n2
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(xor
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call n2 ("peer" "identify") [] ident1)
|
||||
(call n2 ("dist" "list_blueprints") [] blueprints1)
|
||||
)
|
||||
(call n2 ("dist" "list_modules") [] modules1)
|
||||
)
|
||||
(call n2 ("srv" "list") [] services1)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
|
||||
)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(call n ("event" "all_info") [n2 ident1 services1 blueprints1 modules1])
|
||||
)
|
||||
(next n2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(next n)
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
(call %init_peer_id% ("op" "identity") [])
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
|
||||
)
|
||||
(call -relay- ("op" "identity") [])
|
||||
)
|
||||
)
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("op" "identity") [])
|
||||
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 6])
|
||||
)
|
||||
)
|
||||
|
||||
`,
|
||||
)
|
||||
.configHandler((h) => {
|
||||
h.on('getDataSrv', '-relay-', () => {
|
||||
return client.relayPeerId;
|
||||
});
|
||||
h.on('getDataSrv', 'relayPeerId', () => {return relayPeerId;});
|
||||
h.on('getDataSrv', 'knownPeers', () => {return knownPeers;});
|
||||
|
||||
h.onEvent('errorHandlingSrv', 'error', (args) => {
|
||||
// assuming error is the single argument
|
||||
const [err] = args;
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.handleScriptError(reject)
|
||||
.handleTimeout(() => {
|
||||
reject('Request timed out for getAll');
|
||||
})
|
||||
.build();
|
||||
});
|
||||
await client.initiateFlow(request);
|
||||
return Promise.race([promise, Promise.resolve()]);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import {
|
||||
import { Elm } from './Main.elm';
|
||||
import * as serviceWorker from './serviceWorker';
|
||||
import { eventType } from './types';
|
||||
import { getAll } from './_aqua/app';
|
||||
|
||||
const relayIdx = 3;
|
||||
|
||||
@ -123,9 +124,8 @@ function event(name, peer, peers, identify, services, modules, blueprints) {
|
||||
}
|
||||
});
|
||||
|
||||
app.ports.sendParticle.subscribe(async (part) => {
|
||||
const particle = new Particle(part.script, part.data, 45000);
|
||||
await sendParticle(client, particle);
|
||||
app.ports.getAll.subscribe(async (data) => {
|
||||
await getAll(client, data.relayPeerId, data.knownPeers);
|
||||
});
|
||||
})();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user