Implementation of the Reverse Entropy Hash Clock.
- uuid: bytes
- state: tuple[int, bytes]
- updater: HashClockUpdater
__init__(uuid: bytes = <factory>, state: tuple[int, bytes] = None, updater: HashClockUpdater = None):
Set up the instance if it hasn't been set up yet and return the updater for the clock. If it has been set up (i.e. has a uuid), return the updater if there is one or None.
Read the current state of the clock.
Determine if ts1 happens before ts2.
Determine if ts1 and ts2 are incomparable.
Determines if the clock can possibly receive further updates.
Determines if the clock has provably terminated.
Update the clock if the state verifies.
Verifies the state.
Verifies the timestamp is valid for this clock.
Pack the clock down to bytes.
Unpack a clock from bytes.
Implementation of ClockUpdaterProtocol for the Reverse Entropy Hash Clock.
- seed: bytes
- uuid: bytes
- max_time: int
Set up a new instance.
Create an update that advances the clock to the given time.
Pack the clock updater into bytes.
Unpack a clock updater from bytes.
A vector clock comprised of HashClocks.
- uuid: bytes
- node_ids: list[bytes]
- clocks: dict[bytes, HashClock]
__init__(uuid: bytes = <factory>, node_ids: list[bytes] = None, clocks: dict[bytes, HashClock] = <factory>):
Set up the vector clock. The clock_uuids parameter must be a dict that maps node_id to clock.uuid.
@classmethod create(uuid: bytes, node_ids: list[bytes], clock_uuids: dict[bytes, bytes] = {}) -> VectorHashClock:
Create a vector clock. The clock_uuids parameter must be a dict that maps node_id to clock.uuid.
Read the clock as dict mapping node_id to tuple[int, bytes]. Return value includes vector clock uuid at the key b'uuid' and is the timestamp used for causality comparisons.
Create an update to advance the clock given the output of a call to advance
from the underlying HashClock associated with the given node_id.
Update the clock using a dict mapping node_id to tuple[int, bytes]. The state
must also include the vector clock uuid at the key b'uuid'. The expected input
is the output of the advance method.
Verify that all underlying HashClocks are valid.
Verify that the timestamp is valid. Expected input is the output of read or
advance.
Determine if ts1 happens before ts2. As long as at least one node_id contained
in both timestamps has a higher value in ts1 and no node_id shared by both has a
higher value in ts2, ts1 happened-before ts2. Valid timestamps are generated by
the advance and read methods.
Determine if ts1 and ts2 are incomparable. As long as the two timestamps share one node_id in common, they are comparable.
Determine if ts1 and ts2 are concurrent.
Pack the clock into bytes.
Unpack a clock from bytes.
Implementation of the Reverse Entropy Point Clock (Ed25519).
- uuid: bytes
- state: tuple[int, bytes]
- updater: PointClockUpdater
__init__(uuid: bytes = <factory>, state: tuple[int, bytes] = None, updater: PointClockUpdater = None):
Set up the instance if it hasn't been setup yet and return the updater for the clock. If it has been setup (i.e. has a uuid), return the updater if there is one or None.
Read the current state of the clock.
Determine if ts1 happens before ts2.
Determine if ts1 and ts2 are incomparable.
Update the clock if the state verifies.
Verifies the state.
Verify the timestamp is valid for this clock.
Verify a signed timestamp contains both a valid timestamp and a valid signature from the pubkey in the timestamp.
Pack the clock down to bytes.
Unpack a clock from bytes.
Implementation of ClockUpdaterProtocol for the Reverse Entropy Point Clock.
- seed: bytes
- uuid: bytes
- max_time: int
Set up a new instance.
Create an update that advances the clock to the given time.
Create an update that advances the clock to the given time and provide a signature that verifies for the public key. Return format is (ts, pubkey, signature).
Pack the clock updater into bytes.
Unpack a clock updater from bytes.
A vector clock comprised of PointClocks.
- uuid: bytes
- node_ids: list[bytes]
- clocks: dict[bytes, PointClock]
__init__(uuid: bytes = <factory>, node_ids: list[bytes] = None, clocks: dict[bytes, PointClock] = <factory>):
Set up the vector clock. The clock_uuids parameter must be a dict that maps node_id to clock.uuid.
@classmethod create(uuid: bytes, node_ids: list[bytes], clock_uuids: dict[bytes, bytes] = {}) -> VectorPointClock:
Create a vector clock. The clock_uuids parameter must be a dict that maps node_id to clock.uuid.
Read the clock as dict mapping node_id to tuple[int, bytes]. Return value includes vector clock uuid at the key b'uuid' and is the timestamp used for causality comparisons.
Create an update to advance the clock given the output of a call to advance or
advance_and_sign from the underlying PointClock associated with the given
node_id.
Update the clock using a dict mapping node_id to tuple[int, bytes] or tuple[int,
bytes, bytes]. The state must also include the vector clock uuid at the key
b'uuid'. The expected input is the output of the advance method.
Verify that all underlying PointClocks are valid.
Verify that the timestamp is valid. Expected input is the output of read or
advance.
Verify that a timestamp which includes a signature is valid. This timestamp must
be produced by passing the output of advance_and_sign from an underlying
PointClock to the advance method on the VectorPointClock.
Determine if ts1 happens before ts2. As long as at least one node_id contained
in both timestamps has a higher value in ts1 and no node_id shared by both has a
higher value in ts2, ts1 happened-before ts2. Valid timestamps are generated by
the advance and read methods.
Determine if ts1 and ts2 are incomparable. As long as the two timestamps share one node_id in common, they are comparable.
Determine if ts1 and ts2 are concurrent.
Pack the clock into bytes.
Unpack a clock from bytes.