-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ask ipfs.config for gateway address where possible #309
Conversation
Detect when the ipfs gateway is running on a port other than 8080
One thing that was tricky with the current set up was I couldn't see a way to know if the user had explicitly set an option, or if it had be added in by |
Hello @olizilla! Getting Gateway address from API is indeed a neat idea! 👌 I've come up with some UX edge cases that need to be addressed before we merge it:
If you have time, feel free to work on it here 👍
It sounds good on paper, but my experience is that you quickly run into layers of checks and orchestration that increases complexity and degrades performance. I feel some background is due here: To avoid reading various options multiple times on every request, background script maintains a local You may think that is a problem, as we are unable to tell if an option "was missing, so we used the default" or "was manually set by the user to a value that just happens to be the default". In reality if you need to differentiate between the two you run into a risk of false-positives, which is a sign of a deeper UX problem. In case of I hope I did not make things worse with this elaboration, wanted to be thorough 🙂 I am aware some code patterns were ported from legacy add-on and may not feel "idiomatic" in webextension, but keep in mind when we started rewrite there were no webextensions around. |
@lidel this is really helpful, thank you for taking the time to write it up. I'll pin down the use-cases and figure out a plan.
👍 💯 ✨ strongly agree! I really like that this add-on is focused it is on giving a good user-experience for ipfs.
Don't worry, I totally know that feeling. It's all good! I've jumped in here because I think this add-on is doing a great job and the brave integration is best achieved by helping out with ipfs-companion rather than making another bespoke thing! |
add-on/src/lib/ipfs-companion.js
Outdated
const buff = await ipfs.config.get() | ||
return JSON.parse(buff.toString()) | ||
} catch (err) { | ||
console.log('Failed to get IPSF config', err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: IPSF
} | ||
|
||
async function getGatewayUrl (ipfs) { | ||
const config = await getIpfsConfig(ipfs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just fetch the Addresses.Gateway
value?
$ ipfs config 'Addresses.Gateway'
/ip4/127.0.0.1/tcp/8080
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure can. I thought that getting the entire ipfs config might provide other useful info. Perhaps we won't ever need it, but I don't think it's a bad gamble.
package.json
Outdated
@@ -65,6 +66,7 @@ | |||
"ipfs-api": "15.0.1", | |||
"is-ipfs": "0.3.2", | |||
"lru_map": "0.3.3", | |||
"multiaddr": "^3.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the rest are pinned
This feature will be delivered as a part of #491 (comment) so I am closing this PR in favor of addressing it there. |
Hi @lidel 👋
This PR aims to make a small improvement to the out-o-the-box experience, by asking the ipfs api what it's config and using that where the user hasn't provided a non default override. This PR is deliberately the smallest change that could work, as I'm new here, and wanted to get your thoughts on it.
I'm working on integrating ipfs into brave, building on top of the work that @diasdavid has done. I'd like to get ipfs-companion working in brave, but the first issue I hit was I had to run my local ipfs gateway on a port other than 8080 as the brave dev process uses 8080, so I figured I could learn a thing by getting ipfs-companion to find the gateway port from the api.