cancel method

Implementation

CommandApplyStatus cancel(CommandCancel cancel) {
  if (_seenCancelIds.contains(cancel.causationId)) {
    return const CommandApplyDuplicate();
  }
  final entry = _entries[cancel.commandId];
  if (entry == null) return const CommandApplyUnknown();
  if (cancel.authorityGeneration != entry.generation) {
    return CommandApplyStaleGeneration(
        entry.generation, cancel.authorityGeneration);
  }
  _seenCancelIds.add(cancel.causationId);
  // A cancel is non-terminal by itself; the rejected receipt makes it terminal.
  return const CommandApplyRecorded();
}