Explore Courses Blog Tutorials Interview Questions
0 votes
in Blockchain by (4.1k points)

I am writing a decentralized chat application using nodejs, expressjs, angularjs, and ipfs.I am using libp2p to form the nodes that will communicate with each other over an open connection. Libp2p is a networking stack modularized out of IPFS project.

Libp2p allows me to build nodes which are capable of hosting a swarm or listening/ dialing to one. I have developed to the point where several nodes can communicate with each other via inputs in angularjs (supplemented by webpage but their IP addresses and tcp ports need to be hard coded.

The problem I am facing is, if an unknown number of users join this system and set up their nodes, how do I handle the scenario. I have done lot of research into DHT specifically into its application with torrents but am no where close to actually applying it.

I do not want to run a central system that keeps track of the users as a tracker keeps track of seeders and leachers in torrents (now somewhat redundant due to DHT)

In a centralized chat application, every time a user enters or leaves, I can send an emit event from the server to all peers using signaling the same. But the equivalent in a decentralized chat app is something I am struggling with greatly.

I need some guidance please.

1 Answer

0 votes
by (14.4k points)

As a matter of fact, libp2p will implicitly take care of the discovery and connection of nodes. So, you need not worry about the issue. Moreover, libp2p will also aid you with a primitive for process addressing. This primitive will dial or invoke the process if it is accessible within the network. 

Browse Categories