Back to articles
P2P For Web Devs, Part 1.1: dht-rpc

P2P For Web Devs, Part 1.1: dht-rpc

via Dev.toerndob

Previous articles: P2P For Web Devs, Prologue: Why should I care? P2P For Web Devs, Part 1: Networking dht-rpc dht-rpc is a Kademlia based DHT implementation. Quick refresher: Distributed Hash Table (DHT) stores data across different nodes in some kind of shared key space. Kademlia defines how we store data and find the exact node that holds the hash key you are looking for. It's one of the ways to implement a DHT. Let's build our own DHT and see what happens. I might mention some things that might make no sense yet, but as you read this article we will go back to those concepts and it will click. We have absolutely nothing now. Let's create the very first node. import DHT from ' dht-rpc ' const node = new DHT () This single new DHT() statement does A LOT. It's an instance of EventEmitter that during constructor execution will: Create a kademlia routing table Open UDP sockets and start listening. Starts watching network interfaces, health, and ticking to react to changes and maintain t

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles