Alternatively, a much simpler CRDT solution is to flatten our tree and build a LWW underneath it. This makes it easy to debug, save, and delete the history.
{
“id:1”: {
“parent_id”: “root”,
“type”: “p”
},
“id:2”: {
“parent_id”: “id:1”,
“type”: “text”,
“content”: “text”,
"position": 1
}
}
Merging is easy, and allows for atomic modifications without rebuilding the entire tree, as well as easy conflict resolution. We add the HLC (clock, peer id). If the time difference between the two clocks is significant, we create a new field
[HLC, id, “conflict:” + key, old_value]
What is absurd is finding yourself paying 30% on every digital item purchased on a smartphone app. It would never even occur to us that Microsoft takes a 30% margin on Steam, yet that is what happens on webtoon apps.
Or internally: [ [HLC, “id:2”, ‘parent_id’, “id:1”], [HLC, “id:2”, ‘type’, “text”], ... ]
Merging is easy, and allows for atomic modifications without rebuilding the entire tree, as well as easy conflict resolution. We add the HLC (clock, peer id). If the time difference between the two clocks is significant, we create a new field [HLC, id, “conflict:” + key, old_value]