swarm v3.0.2 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.

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 it’s identity, useful for sending the clock with messages, but cannot be used to track events

Creates a new interval tree clock

Types

int_tuple()
int_tuple :: {non_neg_integer, non_neg_integer}
t()
t ::
  int_tuple |
  {int_tuple, non_neg_integer} |
  {non_neg_integer, int_tuple} |
  {int_tuple, int_tuple}

Functions

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)

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

Decodes the clock from a binary

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.

len(d)
len(Swarm.IntervalTreeClock.t) :: non_neg_integer

Returns the length of the encoded binary representation of the clock

leq(arg1, arg2)

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 it’s identity, useful for sending the clock with messages, but cannot be used to track events.

Creates a new interval tree clock

str(arg)