mirror of
https://github.com/fluencelabs/dashboard
synced 2024-12-04 23:30:20 +00:00
42 lines
1.8 KiB
Plaintext
42 lines
1.8 KiB
Plaintext
import "@fluencelabs/aqua-lib/builtin.aqua"
|
|
|
|
alias PeerInfoCb: PeerId, Info, []Service, []Blueprint, []Module -> ()
|
|
alias ServiceInterfaceCb: PeerId, string, Interface -> ()
|
|
|
|
func collectServiceInterfaces(peer: PeerId, services: []Service, collectServiceInterface: ServiceInterfaceCb):
|
|
for srv <- services par:
|
|
on peer:
|
|
iface <- Srv.get_interface(srv.id)
|
|
collectServiceInterface(peer, srv.id, iface)
|
|
|
|
func askAllAndSend(peer: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
|
|
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)
|
|
|
|
|
|
func findAndAskNeighboursSchema(relayPeerId: PeerId, clientId: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
|
|
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)
|
|
|
|
func getAll(knownPeers: []PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
|
|
on HOST_PEER_ID:
|
|
-- co askAllAndSend(relayPeerId, collectPeerInfo, collectServiceInterface)
|
|
|
|
-- in order to temporarily reduce the number of particles sent to client
|
|
-- 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)
|
|
|
|
-- co findAndAskNeighboursSchema(relayPeerId, %init_peer_id%, collectPeerInfo, collectServiceInterface)
|