digidem / mapeo-core

Library for creating custom geo data and syncronizing via a peer to peer network
23 stars 2 forks source link

Cannot assume that peer.name is unique #83

Closed gmaclennan closed 4 years ago

gmaclennan commented 4 years ago

There are a couple of places in the sync code where peer.name is used as a lookup for a peer e.g.

On mobile we (currently) randomly generate the name (but plan to change this in the future) but on Desktop we use the computer hostname as the name. I just realised that in the field it is quite common for computers to have identical hostnames (e.g. something like "Windows PC"), especially when multiple machines have been deployed at the same time. I think this would result in the completed states not being updated correctly.

okdistribute commented 4 years ago

Yes that's right.. originally I think this used peer.id, but we realized that ids don't persist between connections so this was a hack. The next version of mapeo-core should use peer.id, since they persist between connections.

hackergrrl commented 4 years ago

Agreed that using name is problematic.

What level of consistency is desired?

  1. consistent across reconnects (session-wide)
  2. consistent across sessions (permanent to the device)

If the former, a random ID at startup is fine. If the latter, we could use a hash of the device's writeable hypercore public key.

gmaclennan commented 4 years ago

I think (2) - permanent to device, because during the process of sync a user might close the mobile app and return to it, or quit and re-open the desktop app, so if it errored then a reconnect after app restart should be able to link to the same peer

hackergrrl commented 4 years ago

This will be fixed by #87.