magicdawn / magicdawn

个人学习 / 代码 / 总结 / 读书笔记
25 stars 3 forks source link

Shared Editing: OT / CRDT #160

Open magicdawn opened 1 year ago

magicdawn commented 1 year ago

CRDT / OT

CRDT = Conflict-free replicated data types OT = operational transformation

magicdawn commented 11 months ago

OT

magicdawn commented 11 months ago

CRDT

YATA / yjs

资料

YATA 论文理解

We define < as the natural predecessor relation on S.

核心规则: origin 线不想交

Xnip2024-06-28_08-15-29

如果 o2 在 o1 后面, (o1 < o2), 那么

至于 o1 = o2.origin, 不知这种情况如何处理


// Insert ’i’ in a list of
// conflicting operations ’ops ’.
insert(i, ops){
  i.position = ops[0].position
  for o in ops do
    // Rule 2:
    // Search for the last operation
    // that is to the left of i.
    if (o < i.origin OR i.origin <= o.origin)
      AND (o.origin != i.origin OR o.creator < i.creator) do
      // rule 1 and 3:
      // If this formula is fulfilled , 
      // i is a successor of o.
      i.position = o.position + 1
    else do
      if i.origin > o.origin do
      // Breaking condition ,
      // Rule 1 is no longer satisfied 
      // since otherwise origin connections would cross
      break
}