swarm v3.1.0 Swarm.IntervalTreeClock

This is an implementation of an Interval Clock Tree, ported from the implementation in Erlang written by Paulo Sergio Almeida psa@di.uminho.pt found here.

Link to this section Summary

Functions

Compares two clocks. If :eq is returned, the two clocks are causally equivalent If :lt is returned, the first clock is causally dominated by the second If :gt is returned, the second clock is causally dominated by the first If :concurrent is returned, the two clocks are concurrent (conflicting)

Decodes the clock from a binary

Encodes the clock as a binary

Records an event on the given clock

Forks a clock containing a shared causal history, used for creating new replicas

Joins two forked clocks into a single clock with both causal histories, used for retiring a replica

Returns the length of the encoded binary representation of the clock

Determines if the left-hand clock is causally dominated by the right-hand clock. If the left-hand clock is LEQ than the right-hand clock, and vice-versa, then they are causally equivalent

Gets a snapshot of a clock without its identity. Useful for sending the clock with messages, but cannot be used to track events

Creates a new interval tree clock

Link to this section Types

Link to this type int_tuple()
int_tuple() :: {non_neg_integer(), non_neg_integer()}
Link to this type t()
t() ::
  int_tuple() |
  {int_tuple(), non_neg_integer()} |
  {non_neg_integer(), int_tuple()} |
  {int_tuple(), int_tuple()}

Link to this section Functions

Link to this function compare(a, b)
compare(Swarm.IntervalTreeClock.t(), Swarm.IntervalTreeClock.t()) ::
  :lt |
  :gt |
  :eq |
  :concurrent

Compares two clocks. If :eq is returned, the two clocks are causally equivalent If :lt is returned, the first clock is causally dominated by the second If :gt is returned, the second clock is causally dominated by the first If :concurrent is returned, the two clocks are concurrent (conflicting)

Link to this function decode(b)
decode(binary()) ::
  {:ok, Swarm.IntervalTreeClock.t()} |
  {:error, {:invalid_clock, term()}}

Decodes the clock from a binary

Link to this function encode(arg)
encode(Swarm.IntervalTreeClock.t()) :: binary()

Encodes the clock as a binary

Records an event on the given clock

Forks a clock containing a shared causal history, used for creating new replicas.

Joins two forked clocks into a single clock with both causal histories, used for retiring a replica.

Link to this function len(d)
len(Swarm.IntervalTreeClock.t()) :: non_neg_integer()

Returns the length of the encoded binary representation of the clock

Determines if the left-hand clock is causally dominated by the right-hand clock. If the left-hand clock is LEQ than the right-hand clock, and vice-versa, then they are causally equivalent.

Gets a snapshot of a clock without its identity. Useful for sending the clock with messages, but cannot be used to track events.

Creates a new interval tree clock