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

Prevent re-applying locally defined Commit #90

Closed
joepio opened this issue Sep 20, 2021 · 1 comment
Closed

Prevent re-applying locally defined Commit #90

joepio opened this issue Sep 20, 2021 · 1 comment

Comments

@joepio
Copy link
Member

joepio commented Sep 20, 2021

When a user creates a Commit and sends this to the server, the server might confirm this and send that same commit back through websockets. This could cause a previous state to overwrite the current state.

Ideally, commits are ignored by the client if they are already applied. I think we could store in Resources which commit has been applied.

Store a Set of applied signatures

A simple solution, which should work just fine for the issue mentioned here, but there is a more elegant approach.

Always check 'previous commit' signatures in Commits before applying

Resources can store their previousCommit, which is the last applied signature. We should also include these in every Commit, so it's clear what the state was of a resource before committing.

If the client receives a commit with a signature that is the same as the previousCommit found in the local Resource, we can ignore it. If the received Commit's previousCommit matches the previousCommit, we can apply it. If they differ, the Client should check whether the commit has been applied before (if it exists in the set). If it does not, and the previousCommit does not match, the client has come out of sync, and needs to re-fetch the Resource. This resource should then contain a previousCommit.

@joepio
Copy link
Member Author

joepio commented Sep 20, 2021

I've opted for the (simple) solution of storing all signatures in the Resource.

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

No branches or pull requests

1 participant