ipfs-companion
ipfs-companion copied to clipboard
Add Peer URI Hint Experiment
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
I would be interested in taking this up...if you can guide me a bit about it... point me to the right file...
@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:
- building:
npm run dev-build
it will take care of everything (fetching dependencies, building) - 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:
- Add new boolean option in options.js#L12 (eg.
peerUriHints
) - Add UI for enabling/disabling the experiment to experiments-form.js, you can use
linkify
as an example. - Add i18n labels to _locales/en/messages.json (just `english, other ones are handled by Transifex)
- make hint detection enabled only when
peerUriHints: true
- decide if this experiment should be enabled by default
- Bikeshed the final hint name. When we ship this, people will start using it to speed up content discovery. I proposed
provs
(we already haveipfs dht findprovs
) but we should really get a consensus on the name before we ship it :)
Thank You!
I will go through the above steps ... If I get stuck somewhere I might bug you again.
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)
Related IPIP: https://github.com/ipfs/specs/pull/322