Open FelixSelter opened 2 years ago
Hi @FelixSelter, thanks for writing this up. I think the code example is not quite correct though. If I read it correctly, you're taking a message from Automerge.generateSyncMessage()
and broadcasting it to several connected peers. That's not safe, because a sync message is always specific to two particular peers. You need a separate syncState for each connected peer, and generate a separate sync message to send to each connected peer.
I will correct that. Strange it actually worked for me with multiple peers
@ept Can you please have a look at it again. It still seems wrong. 1 syncs with 2 2 applies the changes and sees that it does not need to sync back to 1
However if peer1 calls sync again without changing anything it will send out changes to peer2 which also applies them.
Thanks for doing this @FelixSelter - this is super helpful to understand the protocol with implementation details.
I added a simple example of two peers connecting and syncing a document.
This should make things more clear and avoid issues like this one #437
Previously you had to investigate the tests to understand this correctly
I hope this helps. Great work you all