Пример #1
0
 // Tail recursion
 public Replica ApplyRemote()
 => match(FindApplicableRemoteOp(),
          Some: op => Copy(
              opsCounter: bigint.Max(OpsCounter, op.Id.OpsCounter),
              document: Document.ApplyOp(op, this),
              processedOps: ProcessedOps.Add(op.Id)).ApplyRemote(),
          None: () => this);
Пример #2
0
 private Option <Operation> FindApplicableRemoteOp()
 {
     return(ReceivedOps.Find(op
                             => !ProcessedOps.Contains(op.Id) &&
                             op.Deps.IsSubsetOf(ProcessedOps)));
 }
Пример #3
0
 public Replica ApplyLocal(Operation operation)
 => Copy(
     document: Document.ApplyOp(operation, this),
     processedOps: ProcessedOps.TryAdd(operation.Id),
     generatedOps: GeneratedOps.Add(operation));