get-ipfs
get-ipfs copied to clipboard
Normalized connect
Summary
Problem
Different daemons can only connect to certain addresses. Local daemons need tcp or ws, in-browser daemons need wss or webRTC (when over https).
Impact
When doing a swarm.connect, you first need to figure what context the node comes from and then connect to an address that fits that context
Solution
- Add an additional property to the returned ipfs object that gives it's source. ie:
ipfs.source = 'local' | 'browser'
- Add an additonal method that takes multiple address types and connects to the proper one depending on the source. Param can be similar to the peers passed on instantiation ie:
ipfs.normalized.swarm.connect({
peers: [],
localPeers: [],
browserPeers: []
})