libp2p / go-libp2p-examples

Example libp2p applications
MIT License
339 stars 145 forks source link

Add Example of private network / DHT configuration #156

Open willscott opened 4 years ago

willscott commented 4 years ago

The current host example doesn't default to becoming a self-sustaining DHT mesh. It would be useful to add an example using the Dual DHT from go-libp2p-kad-dht to demonstrate that configuration.

alabianca commented 4 years ago

I ran into the issue of DHT Get Value not working because nodes aren't found a few days ago when playing around with some of the examples. I created a new example that uses the dht.PutValue and dht.GetValue to put and retrieve values from the dht. It worked fine in the examples repo, but not outside of it. The reason why it worked in the examples is that it uses go-libp2p-kad-dht version 0.5.0. My example outside of the repo uses version 0.7.10 which always returned an error when trying to dht.GetValue or dht.PutValue.

I replaced the dht.New(ctx, host) with dual.New(ctx, host) from github.com/libp2p/go-libp2p-kad-dht/dual and it worked. I am still trying to wrap my head around why it worked exactly

xiaokugua250 commented 4 years ago

+1 and @alabianca will you show your code example please ! thanks a lot