RangerMauve / hyperswarm-web

Implementation of the hyperswarm API for use in web browsers
MIT License
102 stars 15 forks source link

Full mesh vs partial mesh #21

Closed draeder closed 2 years ago

draeder commented 2 years ago

I'm just circling back to this..

Setting details.client = false for all new connections seems to full mesh between peers..

swarm.on('connection', (socket, details) => {
  details.client = false
  console.log('new connection!', details)

  process.stdin.pipe(socket)
  socket.pipe(process.stdout)
})

However, 2 of 3 connections I tested with seem to have the same host ID. Is this expected? In 'normal' hyperswarm, this doesn't seem to be the case..

Is this use case supported?

draeder commented 2 years ago

Disregard - I think I already asked a similar question https://github.com/RangerMauve/hyperswarm-universal-chat/issues/2.

draeder commented 2 years ago

It seems like the initial two connections always establish reliably. The subsequent connections are hit or miss. I think I can work on relaying peer signaling from the reliable connection to the others. Or simply fallback to a gossip protocol of sorts.

draeder commented 2 years ago

As I've been thinking about this, it's working exactly as it should. It is a partial mesh by default thanks to @geut/discovery-swarm-webrtc. A gossip protocol protocol to relay messages is all that is really needed here, for my purposes anyway.

RangerMauve commented 2 years ago

Yeah, one of the reasons it's a partial mesh is that WebRTC connections are super expensive. I'm not against adding the ability for full mesh if it's absolutely necessary, but I wouldn't have time to work on that myself and would need some PRs + tests. 😁