ipfs-companion icon indicating copy to clipboard operation
ipfs-companion copied to clipboard

Add Peer URI Hint Experiment

Open lidel opened this issue 5 years ago • 5 comments

ipfs://{cid}?provs={multiaddr1},{peerId2},{peerId3}` 
http://127.0.0.1:8080/ipfs/{cid}?provs={multiaddr1},{peerId2},{peerId3}

The idea is to detect above hints and connect to listed peers to improve content discovery speed if possible. Due to potential privacy considerations, this should start as opt-in experiment.

Ref.

  • https://discuss.ipfs.io/t/proposal-peer-hint-uri-scheme/4649?u=lidel

lidel avatar May 19 '19 19:05 lidel

I would be interested in taking this up...if you can guide me a bit about it... point me to the right file...

heypran avatar Jun 01 '19 12:06 heypran

@heychessy thank you! I wrote some notes to get you oriented, let me know if you have any questions or something is confusing, will be happy to help and explain :)

Step 0: set up dev

We have some developer notes in /docs/developer-notes.md, but in short:

  1. building: npm run dev-build it will take care of everything (fetching dependencies, building)
  2. testing: run npm run firefox to start browser with extension loaded in it

Step 1: wire up hint detection

Core logic responsible for handling HTTP requests is in src/lib/ipfs-request.js.

I believe you add hint detection inside of existing onBeforeRequest listener. Basically you would check if URL of processed request includes provs parameter, and if so, make asynchronous ipfs.swarm.connect calls to all peers listed in its value.

This should be enough for you to open a PR and iterate there :)

Step 2: add it as experiment in Preferences

This can be added later, when we are happy with step 1, making it ready for shipping:

  1. Add new boolean option in options.js#L12 (eg. peerUriHints)
  2. Add UI for enabling/disabling the experiment to experiments-form.js, you can use linkify as an example.
  3. Add i18n labels to _locales/en/messages.json (just `english, other ones are handled by Transifex)
  4. make hint detection enabled only when peerUriHints: true
  5. decide if this experiment should be enabled by default
  6. Bikeshed the final hint name. When we ship this, people will start using it to speed up content discovery. I proposed provs (we already have ipfs dht findprovs) but we should really get a consensus on the name before we ship it :)

lidel avatar Jun 02 '19 13:06 lidel

Thank You!

I will go through the above steps ... If I get stuck somewhere I might bug you again.

heypran avatar Jun 02 '19 13:06 heypran

For the record, I think https://github.com/ipfs-shipyard/ipfs-companion/issues/925 is a safer approach and should be prioritized instead. (unlike this, does not hardcode peersids/addrs in the shared link, enables scaling/delegation without user's involvement)

lidel avatar Jan 19 '21 17:01 lidel

Related IPIP: https://github.com/ipfs/specs/pull/322

lidel avatar Nov 22 '22 02:11 lidel