Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a simple example to help understanding the sync protocol #458

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

FelixSelter
Copy link

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

@ept
Copy link
Member

ept commented Jan 3, 2022

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.

@FelixSelter
Copy link
Author

I will correct that. Strange it actually worked for me with multiple peers

@FelixSelter
Copy link
Author

@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.

@timfpark
Copy link

Thanks for doing this @FelixSelter - this is super helpful to understand the protocol with implementation details.

echarles pushed a commit to datalayer-externals/automerge-classic-arch that referenced this pull request Feb 16, 2023
…rn/javascript/examples/create-react-app/loader-utils-2.0.4

Bump loader-utils from 2.0.2 to 2.0.4 in /javascript/examples/create-react-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants