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

Normalized connect

Open dholms opened this issue 6 years ago • 0 comments

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: []
})

dholms avatar Sep 28 '19 01:09 dholms