Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions aqua/app.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,48 @@ import "@fluencelabs/aqua-lib/builtin.aqua"
alias PeerInfoCb: PeerId, Info, []Service, []Blueprint, []Module -> ()
alias ServiceInterfaceCb: PeerId, string, Interface -> ()

-- send all found ServiceInterface-s to the client
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)

-- retrieve PeerInfo & ServiceInterface-s from a single peer
func askAllAndSend(peer: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
on peer:
ident <- Peer.identify()
blueprints <- Dist.list_blueprints()
modules <- Dist.list_modules()
services <- Srv.list()
collectPeerInfo(peer, ident, services, blueprints, modules)
collectServiceInterfaces(peer, services, collectServiceInterface)
-- collectServiceInterfaces(peer, services, collectServiceInterface)

-- retrieve PeerInfo and ServiceInterface-s from each peer in `peers`
func getServicesFromPeers(
peers: []PeerId,
collectPeerInfo: PeerInfoCb,
collectServiceInterface: ServiceInterfaceCb
):
for peer <- peers par:
askAllAndSend(peer, collectPeerInfo, collectServiceInterface)

func findAndAskNeighboursSchema(relayPeerId: PeerId, clientId: PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
on relayPeerId:
neighbors <- Kademlia.neighborhood(clientId, false)
-- discover new nodes in the network and report findings back to client
func discoverNeighbourhood(relay: PeerId, collectNeighbors: []string -> ()):
on relay:
neighbors <- Kademlia.neighborhood(%init_peer_id%, nil, nil)
co collectNeighbors(neighbors)
for n <- neighbors par:
on n:
neighbors2 <- Kademlia.neighborhood(clientId, false)
for n2 <- neighbors2 par:
askAllAndSend(n2, collectPeerInfo, collectServiceInterface)

func getAll(relayPeerId: PeerId, knownPeers: []PeerId, collectPeerInfo: PeerInfoCb, collectServiceInterface: ServiceInterfaceCb):
-- 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)
neighbors2 <- Kademlia.neighborhood(%init_peer_id%, nil, nil)
collectNeighbors(neighbors2)

-- co findAndAskNeighboursSchema(relayPeerId, %init_peer_id%, collectPeerInfo, collectServiceInterface)
func discoverNeighbourhoodFull(relay: PeerId, knownPeers: []PeerId, collectNeighbors: []string -> ()):
for node <- knownPeers par:
on node via relay:
neighbors <- Kademlia.neighborhood(%init_peer_id%, nil, nil)
co collectNeighbors(neighbors)
for n <- neighbors par:
on n:
neighbors2 <- Kademlia.neighborhood(%init_peer_id%, nil, nil)
collectNeighbors(neighbors2)
Loading