libp2p / go-libp2p-examples

Example libp2p applications
MIT License
339 stars 145 forks source link

New dht example for values storages #76

Open rach-id opened 4 years ago

rach-id commented 4 years ago

The idea is to make a network where nodes can add values to the DHT (and not store them locally, a value should be stored in the closest node to its key) and others who have the keys (which for me are sha2-256 multihash) can retrieve these values.

So to get these nodes to be in the same network without having to hardcode the addresses etc. I found the pubsub pattern (the code im using is the pubsub example in the ipfs-camp-2019) that can give me this, and i found a DHT already defined there for routing.

This example uses Provide() to tell nodes that it has a certain CID and peers :