The vector clock is used to keep track of the logical time of the node.
The vector clock is useful when updating a remote node's contact informations in the router.
- constructor
- getters
- methods
options
:start
: Integer (Default: 0) Starting time of the clock.
Creates a new Vector Clock.
const plexus = require("plexus");
// Creating a new Vector Clock
const clock = new plexus.VectorClock();
Returns the current logical time of the node.
const time = clock.time;
console.log(time); // 15
id
: String (Optional, Default: null) The ID of the node that caused the update.
Updates the logical time of the node.
// Node 0xa6564bce963cbfb2e841d2c94d450368c1463b235fb70fb27f2f69285cacf8ed caused an update
clock.update("0xa6564bce963cbfb2e841d2c94d450368c1463b235fb70fb27f2f69285cacf8ed");