> The current implementation does not store the shadows or version
> numbers to disk, which means that after a restart the server has an
> unknown client arriving with an unknown version. In cases like this
> where it is unknowable whether the server messed up or the client
> messed up, the server wins. This way someone with a bad client isn't
> going to poison the system for everyone.
>
> Does this answer the question? If not, let me know and I'll look into
> it more closely.
I probably hid my question too well- The question is: Why does the
server increment the client shadow version to 1 in the example
outlined above, while it tells the client to set it to 0?
> The current implementation does not store the shadows or version
> numbers to disk, which means that after a restart the server has an
> unknown client arriving with an unknown version.
Yes. In this case the server sends an empty 'r:0:' (let's assume that
the server cannot load the text from disk and it's an 'r' not an 'R').
This has the client empty its server shadow and reset its server
shadow version number. Then it sends a diff from its local text, which
is still unmodified, against the (empty) server shadow. So the
client's response would look something like this:
F:0:foobar
d:0:(diff-text)
Now the server runs in the "action["client_version"] <
viewobj.shadow_client_version" part, because it has previously
incremented the shadow_client_version to 1. This means, it doesn't
apply the diff. And since the text is still empty, it sends the client
F:1:foobar
d:0:=0
The client now has a delta mismatch, because that diff is probably not
valid for its client text. So, the client in turn also sends an 'r:'
with its local text, thus ending up in sync again.
If the server had not incremented the version number in the first
place, the server would have simply applied the first diff from the
client to the empty shadow. Also probably hasn't got anything to do
with the server "winning" over the client because the _client_
actually sends the raw update that gets both parties back in sync. So
what am I missing here? :)
Cheers,
Martin