Represents a clock vector, which is a local logical clock together with a set of logical clocks of other peers.

Hierarchy (view full)

Implements

Constructors

Properties

Methods

Constructors

Properties

peers: Map<number, ITimestampStruct> = ...

A set of logical clocks of other peers.

sid: number

Session ID (or actor ID, site ID, process ID, etc.), a random identifier randomly assigned to each editing session.

time: number

Logical time (or sequence number, tick, etc.), a monotonically increasing integer, starting from 0. It does not produce gaps on local machine, but it can produce gaps when merged with other clocks.

Needs to be mutable in vector clock. Other than that, it should be treated as immutable.

Methods

  • Advances local time every time we see any timestamp with higher time value. This is an idempotent method which can be called every time a new timestamp is observed, it advances the local time only if the observed timestamp is greater than the current local time.

    Parameters

    • id: ITimestampStruct

      The time stamp we observed.

    • span: number

      Length of the time span.

    Returns void

  • Returns a human-readable string representation of the clock vector.

    Parameters

    • tab: string = ''

      String to use for indentation.

    Returns string

    Human-readable string representation of the clock vector.