-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: embed provider webrtc maddr into share link #206
base: main
Are you sure you want to change the base?
Conversation
* remove download provider * dispatch begin download in use-current page
maddrs is empty in my share link (I have 0 listen addrs..) so I checked the logs and webrtc is throwing some interesting errors:
I believe this is related to libp2p/js-libp2p#2805.. I wonder if I can get things working by dialing a local kubo node directly.. |
FYI that Daniel and I were able to successfully share a file using the changes in this PR. reviewing code now |
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.
love all the clarification jsdoc items around use effects, and the consolidation of a lot of the code. I would love to break up files-provider a lot more, but i think this is a huge net win. I'm good with merging as is but I left some comments and code suggestions
const decodedMaddrs = maddrs != null ? decodeURIComponent(maddrs).split(',') : null | ||
const multiaddrs = decodedMaddrs != null ? decodedMaddrs.map(maddr => multiaddr(maddr)) : null |
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.
nit: I feel like a separate useMemo
on a maddrs
dep with the fully resolved multiaddrs
would be a little better.. but there is likely little difference.. sometimes react can get wonky if you have different effects too separated.
const decodedMaddrs = maddrs != null ? decodeURIComponent(maddrs).split(',') : null | ||
const multiaddrs = decodedMaddrs != null ? decodedMaddrs.map(maddr => multiaddr(maddr)) : null | ||
|
||
dispatch({ type: 'fetch_start', cid: maybeCid, filename: decodedFilename, providerMaddrs: multiaddrs }) |
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.
I think we need to cancel the fetch on unmount. maybe create an abort controller and pass signal to fetch_start
, and abort on unmount?
dispatch({ type: 'fetch_start', cid: maybeCid, filename: decodedFilename, providerMaddrs: multiaddrs }) | |
const abrtCtl = new AbortController() | |
// ... | |
dispatch({ type: 'fetch_start', cid: maybeCid, filename: decodedFilename, providerMaddrs: multiaddrs, signal: abrtCtl.signal }) | |
return () => { | |
// cancel fetching | |
abrtCtl.abort('unmounted effect..') | |
} |
// TODO: Get only WebRTC addrs dialable from other browsers, e.g. WebRTC Direct, WebRTC Secure WebSockets, and WebRTC WebTransport (currently not included in Helia transports) | ||
return addrs?.filter((addr: Multiaddr) => WebRTC.exactMatch(addr)) ?? [] |
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.
are you talking about:
// TODO: Get only WebRTC addrs dialable from other browsers, e.g. WebRTC Direct, WebRTC Secure WebSockets, and WebRTC WebTransport (currently not included in Helia transports) | |
return addrs?.filter((addr: Multiaddr) => WebRTC.exactMatch(addr)) ?? [] | |
return addrs?.filter((addr: Multiaddr) => WebRTC.exactMatch(addr) || (Circuit.exactMatch(addr) && (WebRTCDirect.matches(addr) || WebTransport.matches(addr) || WebSockets.matches(addr) || WebSocketsSecure.matches(addr)))) ?? [] |
// Whether or not to provide CIDs to the DHT | ||
provideToDHT: boolean |
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.
love this. unfortunately, providing seems to hang forever when this is checked and I add a file.
Also, we will want a TODO
or issue for "reproviding" to DHT if this is checked after files have already been added.
* - For each unpublished file: | ||
* --- Provides the file to the IPFS network | ||
* --- Updates state on success/failure | ||
* - Handles cancellation via AbortController |
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.
i haven't confirmed whether this is working for files that are added when "provide to DHT" is not checked, and then the "provide to DHT" is checked.. but we should be kicking off publishing to DHT and updating UI that something is in progress.
I'll take a look at that. I think the combination of a persisted block/data store and the way we use mfs, causes that to happen naturally (maybe on main too?) |
it totally may be on main.. let me test that out |
its pretty difficult to get main to publish to DHT and get the share link tbh.. |
Background
What's in this PR
Circuit.exactMatch && WebRTC.matches
in order to correctly display the relay dialable address count, e.g. as a browser you are initially only dialable using a circuit relay, which may be over any of the relay's nodes transports, e.g. QUIC, WebSockets etc.use-current-page.ts
) and dispatch an action to the files provider.TODO