How do I create a CRDT using Gun?
For instance, if I want to implement an grow-only array, where each element points to the next, how do I solve conflicts?
To simplify, let's create this scenario, where Alice and Bob are cooperating.
The array contains 3 elements, [a, b, d].
The internal representation of this array would be a linked list like this:
a => b => c
(of course, the internal representation would be something like {value: 'a', next: { value: 'b' next: { value: 'c' }}}), but I think you get my point with the terser notation.
Alice now wants to insert element c between b and d.
Concurrently, Bob wants to insert element C between b and d.
Concurrently, they have this internal representation of the array:
Alice: a => b => c => d
Bob: a => b => C => d
When they join the CRDT, they would converge to either one of the following values:
a => b => c => C => d
or
a => b => C => c => d
No matter what, a) both of them would converge on the same value and b) they would not lose each other's data.
Can we achieve this using Gun?
(This question is a simplification and follow-up question to https://github.com/amark/gun/issues/602)