swarm v1.1.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
Functions
Specs
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)
Specs
decode(binary) ::
{:ok, Swarm.IntervalTreeClock.t} |
{:error, {:invalid_clock, term}}
Decodes the clock from a binary
Specs
Records an event on the given clock
Specs
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.
Specs
len(Swarm.IntervalTreeClock.t) :: non_neg_integer
Returns the length of the encoded binary representation of the clock
Specs
leq(Swarm.IntervalTreeClock.t, Swarm.IntervalTreeClock.t) :: boolean
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.
Specs
Gets a snapshot of a clock without it’s identity, useful for sending the clock with messages, but cannot be used to track events.