Help With Rudimentary IPFS DHT Use

I am wanting to leverage the IPFS DHT (and existing nodes) with as little of the rest of the IPFS infrastructure as possible. Specifically, I want to use go-libp2p-kad-dht to “provide” a cid I have made to the existing network, and then be able to find providers on it later. I don’t want an IPFS filestore I would love to stay only in the libp2p libs if I can. I also want to use my own transport impl, but that bit of information is unimportant for this question.

I have created libp2p host w/ random identity, default peer store, etc and used that and a simple map datastore to instantiate the DHT. Of course, when I attempt to broadcast a provided CID, I get told there are no peers. When calling Bootstrap I see nothing happening and I know based on my own personal Kademlia impls that I need at least one peer hardcoded.

I am finding very little information on doing this. Can anyone help w/ a simple set of code for instantiating a DHT on the existing IPFS DHT and providing a CID? Where are the bootstrap nodes hardcoded? Do I need to set them in my “peerstore” before constructing the DHT? Any help is appreciated as wading through just the libp2p code and/or the ipfs core code is taking me a lot of time right now. Even the test cases which make local peers aren’t really helping me with starting a bootstrap (some use private APIs anyways).

Also, please move this to the proper category if this is not it. Or please let me know a better way to get assistance on a simple DHT setup. Thanks in advance.

florian is has also been working on developing a separate “bootstrap” module to make this simpler but I’ve been having trouble finding time to properly review it.

Thanks for this, especially those node addresses. I will work from here on using that host in the DHT and report back. I would also appreciate any examples of simple uses of go-libp2p-kad-dht but this is definitely enough to get me over the initial hurdle (I was about to do the full IPFS node bootstrap and work backwards killing deps).

Ok, I worked through my bootstrapping issues, custom transport issues, etc and got a PoC up. I opened up another thread: Anonymous DHT Proof-of-Concept Using libp2p and Tor. Thanks for the help, this example and https://github.com/libp2p/go-libp2p/pull/278 were very helpful.

1 Like