A way to visually see who is online and connected as a peer in your Holochain app
PeerVis is a "Zome" that you can include in your Holochain app. This means it is a modular unit of code that is standalone, and won't affect the rest of your code.
To add it to your app, do the following.
- Add the following to the Zomes array in your dna.json
{
"Name": "peerVis",
"Desription": "show whos online",
"CodeFile": "peerVis.js",
"RibosomeType": "js",
"Config": {
"ErrorHandling": "throwErrors"
},
"Entries": [
{
"Name": "peerLink",
"DataFormat": "links"
}
],
"Functions": [
{
"Name": "getPeers",
"CallingType": "json",
"Exposure": "public"
}
]
}
-
Copy the
peerVis
folder INTO thedna
folder of your app -
Copy
peervis.html
andcytoscape.min.js
into theui
folder of your app
When you're running your application, navigate to the localhost address of your app, plus the path /peervis.html
. This will dynamically update and show you who how many other nodes are connected to your node, that the app will be gossiping with.
In order to know who else is online, it attempts to send a node to node message to each peer who has written to the DHT about their presence in the app. Within the peerVis zome, it adds an entry during genesis
announcing their presence within the app.
So it uses the send
method of the api, and listens for a response from other nodes. It does this at a regular interval.