WEEK 4 QUESTIONS | April 25 - May 2, 2021

WEEK 4 QUESTIONS | April 25 - May 2, 2021 (times are in EST)

It’s that time of week again! I’ve attempted to highlight interesting or common questions. This week I’ve been looking at questions involving using DHT in js-ipfs, so I’ve selected a question on that topic and featured it here! I also have some common questions selected which I believe will help newcomers to IPFS which have popped up this week.

Questions

Dmitry Amelchenko asked “Libp2p DHT peer discovery example in JS” (StackOverflow - 17:11 November 9, 2020)

According to Libp2p documentation DHT can be used for peer discovery.

Also, Filecoin claims that they are using libp2p Kademlia DHT for discovering peers in go.

So far I have not been able to find any working examples of how to set it up in JS.

Observation:

I’ve struggled to use DHT in js-ipfs myself, I’d also love to see a working example! (You can find my journey here :sweat_smile:)


nghianguyen119 asked “do you know whether I can connect to the webui of my node on server from other machine?” (Forum - 7:43 April 27) :white_check_mark:

Observation:

This question seems to pop up from time-to-time, so I’ll re-iterate my answer here:

Securely, this should work:

On the node (once)

ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin > '["http://webui.ipfs.io.ipns.localhost:8080", "http://localhost:3000", "http://127.0.0.1:5001", > "https://webui.ipfs.io"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
# RESTART IPFS DAEMON NOW

On the other machine

Every time you want to access the webui remotely, ensure you have an SSH tunnel to the machine on the ports we’ll be using:

ssh -L 5001:localhost:5001 -L 8080:localhost:8080 user@ADDRESS_OF_NODE.COM

Then access the webui here: http://webui.ipfs.io.ipns.localhost:8080/#/welcome


skinkie asked “Instead of duplicating data to chunks, references to the local file” (Forum - 16:53 May 1) :white_check_mark:

From what I understand ipfs add does cryptographical magic, and chucks the original file into the IPFS_PATH. I wonder, was it ever considered not to physically chunk the file, but rather describe the meta data to chunk the original file on the local file system preventing the duplication on the first node.

Observation:

The feature described here exists as an experimental feature FileStore. Once enabled it can be utilised with:

ipfs add --nocopy <filepath>

svntax asked (paraphrased) (Discord - 09:11 April 26) :white_check_mark:

(using browser js-ipfs)

There’s a level editor in my game, and the idea is to be able to upload the “levels” and have others play them. The level data files are stored with IPFS but I don’t know if I set up the game right so that it looks for other nodes if the files aren’t found locally, or if that’s an automatic thing that ipfs does.

Observation

js-ipfs will look for a node that has the file currently from peers, if a peer doesn’t have the file, the file won’t be returned. You can use a Delegate Router to access the DHT, greatly increasing your odds in finding the content. Additionally if the content was only published to the map creator’s node, it’ll only be available while they’re serving the data. To help with initial network propagation, it might be worth-while putting the data on a pinning service or your own nodes temporarily to help people/nodes get, and then ultimately re-share the level data over time.


tysonzero asked “How do I interact with IPFS desktop from the command line?” (Forum - 5:48 April 29) :white_check_mark:

ipfs add and ipfs pin do not show up on IPFS desktop files list.

Observation:

The desktop app’s file list will show the files that are in your MFS! You can add a file to /hello withthe contents Hello world using the following command:

ipfs files cp /ipfs/$(echo "Hello world" | ipfs add -Q) /hello

That’ll add a file named “hello” to your MFS directory with the contents of “Hello world”. Check it out in the app!

1 Like