Skip to content

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

Open
FelixSelter wants to merge 4 commits intoautomerge:mainfrom
FelixSelter:main
Open

Added a simple example to help understanding the sync protocol#458
FelixSelter wants to merge 4 commits intoautomerge:mainfrom
FelixSelter:main

Conversation

@FelixSelter
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Author

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

@FelixSelter
Copy link
Copy Markdown
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
Copy Markdown

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.

3 participants